Support

Home Forums Custom Files Add-on (EE3) Override function in main.php

Override function in main.php

Posted: November 21, 2013 at 9:36 am


Christian Shenouda

November 21, 2013 at 9:36 am

Hi,

I’m trying to override espresso_reg_url in main.php (/includes/functions) to make it compatible with WPML. Is it even possible to just override this function? Because it doesn’t seem to work. Changing it directly in main.php works like a charm though.
Here’s my change:

function espresso_reg_url($event_id = 0) {
global $org_options;
if ($event_id > 0) {
//return espresso_getTinyUrl(home_url().'/?page_id='.$org_options['event_page_id'].'&regevent_action=register&event_id='.$event_id);

//C.Shenouda: We need to get the localized event page
print_r($org_options);
$translated_page = icl_object_id($org_options['event_page_id'], 'page', true);
$new_url = add_query_arg('ee', $event_id, get_permalink($translated_page));
return $new_url;
}/* else {
echo 'No event id supplied'; */
return;
//}
}

Edit: Something weird is going on with the code tags but I hope you can still read it. The actual code isn’t even that important to the issue.

Thanks,
Chris


Tony

  • Support Staff

November 21, 2013 at 10:45 am

Hi Chris,

Pluggable functions as they are referred to are functions wrapped within
this conditional statement:

if(!function_exists('FUNCTION_NAME')) { FUNCTION }

Looking at the code the function you are editing is not pluggable. Which unfortunately means any modifications you make to that function will be overwritten with each Event Espresso update.


Christian Shenouda

November 21, 2013 at 10:49 am

Thank you Tony, for clearing that up.

The support post ‘Override function in main.php’ 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