Events Made Easy Forums How do I … eme_event_preinsert_filter

Tagged: ,

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #52655
    Anonymous
    Inactive

    I have created templates for determining the type of the event.
    When I create a new event and do not want to use the default settings. I choose a template under the heading event format (Drop Down), this document specifies the type of event.

    I use the filter do insert templates for this type:
    Single event format
    RSVP
    Email format
    Event image
    e.g. Attributes

    This works well and is a great improvement

    Now my problem.
    If I create an event with recurrence and default settings, after I have pressed the Save button I see a gray screen. The code seems to stop.
    If I click on event edit, only the first event of the series was added.
    In this case, through the filter the contents of $event are not changed.
    Without the filter there is no problem.

    #52660
    Franky
    Keymaster

    I just tried using this in my functions.php (basically not changing anything):

    
    add_action('eme_event_preinsert_filter','do_my_stuff');
    function do_my_stuff($event) {
       return $event;
    }
    

    and I could create a recurrence just fine …

    Edit: if the code stops, there’s a php error somewhere. Check your webserver error logfiles for clues.

    #52663
    Anonymous
    Inactive

    The error reports are a problem, I can not access the reports.

    OK, I have worked with add_filter, it works well, without recurrence.
    Now I tested the whole thing with add_action, it does not work.
    I can’t change the contents of $event.

    When I look at the file eme_events.php, I found the following code.

    function eme_db_insert_event($event,$event_is_part_of_recurrence=0) {
       ... 
       ...
       if (has_filter('eme_event_preinsert_filter')) $event=apply_filters('eme_event_preinsert_filter',$event);
       ...
       ..
       if (!$event_is_part_of_recurrence && has_action('eme_insert_event_action')) do_action('eme_insert_event_action',$event);
       return $event_ID;
    }

    If I have found the correct code I think I need add_filter, here I can return a value.
    The option with do_action provides no way to return a value.
    I’m not a coder, my thoughts are correct?

    #52666
    Franky
    Keymaster

    No sorry, it needs to be add_filter, not add_action. My bad.
    Let me retest.

    #52667
    Franky
    Keymaster

    I added this to my functions.php:

    
    add_filter('eme_event_preinsert_filter','do_my_stuff');
    function do_my_stuff($event) {
       $event['event_name'].="test";
       return $event;
    }
    

    (just adding the string “test” to each new created event. Works fine for normal and recurring events.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘How do I …’ is closed to new topics and replies.
Scroll to Top