Support

Home Forums Custom Files Add-on (EE3) Custom Files: Cannot redeclare event_espresso_price_dropdown

Custom Files: Cannot redeclare event_espresso_price_dropdown

Posted: April 11, 2013 at 7:04 am


luovajohtaja

April 11, 2013 at 7:04 am

I tried to remove decimals in prices like in this post: https://eventespresso.com/topic/event-price-remove-decimal/

I copied event_espresso_price_dropdown() to custom_functions.php and I get this error:
Fatal error: Cannot redeclare event_espresso_price_dropdown() in …/plugins/espresso-members/member_functions.php on line 345

I didn’t make any changes in that function. The custom_functions.php is in folder: wp-content/uploads/espresso

My Event Espresso version is 3.1.31.1 and WP is 3.5.1. The installation is new and only on my local computer.


Sidney Harrell

April 11, 2013 at 10:01 am

If you look in that file member_functions.php, right above line 345 on line 343, you’ll see a line that needs to be uncommented:

//if (!function_exists('event_espresso_member_price_dropdown')) {

Just remove the two slashes at the start of the line, and place a corresponding ending curly bracket on line 463, after the end of that function. That should prevent the fatal error. If you are modifying that function in the custom files with the members add-on running, then that copy from the members add-on may be the one that you want to copy into the custom files and modify.


luovajohtaja

April 12, 2013 at 3:40 am

Ok. Thanks. I did that and now I get error:

Fatal error: Cannot redeclare event_espresso_price_dropdown() (previously declared in …wp-content/uploads/espresso/custom_functions.php:159) in …/wp-content/plugins/espresso-members/member_functions.php on line 345

On member_functions.php on line 343 it says:

“if (!function_exists(‘event_espresso_member_price_dropdown‘))” and the next function is named “event_espresso_price_dropdown”. So should I name my function in custom_functions.php “event_espresso_price_dropdown” or “event_espresso_member_price_dropdown“. Which one is correct?


Josh

  • Support Staff

April 15, 2013 at 9:12 am

Either can be correct, but they should be consistent. Since you’re trying to override event_espresso_price_dropdown, the conditional check on line 342 should be:

if (!function_exists('event_espresso_price_dropdown')) {

I checked and at one time there was an event_espresso_member_price_dropdown function, but it’s not in the plugin anymore. I’ll make a ticket so the conditional wrapper gets updated in a future version.

The support post ‘Custom Files: Cannot redeclare event_espresso_price_dropdown’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso