Support

Home Forums Custom Files Add-on (EE3) Problem getting Event ID with my custom Filter

Problem getting Event ID with my custom Filter

Posted: October 10, 2013 at 8:24 am

Viewing 2 reply threads


IPES

October 10, 2013 at 8:24 am

Hi There, I took the advice from the thread:
https://eventespresso.com/topic/custom-registration-id/. Very good idea and thanks Support but I’m not out of the woods just yet, I’ve found a problem.

I made my filter and when i use the add_filter code, I don’t seem to be getting the Event ID as an argument. It’s null. Just a thought, I noticed that If i keep both the stock AND my custom filter, then my code works fine.

<code>my_custom_registration_id($event_id){

  //Do something

}

// remove default registration id filter
function my_remove_registration_id_filter() {
	remove_filter(&#039;filter_hook_espresso_registration_id&#039;, &#039;espresso_build_registration_id&#039;, 10);
}
add_filter (&#039;filter_hook_espresso_registration_id&#039;, &#039;my_remove_registration_id_filter&#039;, 9 );

add_filter(&#039;filter_hook_espresso_registration_id&#039;, &#039;my_custom_registration_id&#039;, 10, 1);</code>

Any Ideas ?


Josh

  • Support Staff

October 10, 2013 at 9:13 pm

You can try removing the stock filter within your custom function (instead of another function) like this in order to keep the $event_id value:

//Build the registration id
function my_custom_registration_id($event_id){
  $something = 'something';
  remove_filter('filter_hook_espresso_registration_id', 'espresso_build_registration_id', 10, 1 );
  return $event_id . '-' . $something;
}
		
// add custom registration id filter
add_filter('filter_hook_espresso_registration_id', 'my_custom_registration_id', 9, 1);


IPES

October 11, 2013 at 2:10 am

Excellent! Thanks Josh! That worked perfectly.

Viewing 2 reply threads

The support post ‘Problem getting Event ID with my custom Filter’ 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