• Resolved security_man

    (@security_man)


    I see an apply filters in the duplicate function in em-event.php, but when i try to hook into it there seems to be no effect on the resulting $EM_Events object that is returned.

    What i am trying to do is remove the date’s upon duplication so that the user has to enter new ones in the future before saving. I know a new event is created when the duplicate function is run, but that is okay. If the date is saved with the duplication that is fine, but we want to make sure it cannot be modified without changing the dates in the future.

    function my_remove_dates_on_duplicate($result,$EM_Event) {
    $EM_Event->event_start_date = null;
    return $EM_Event;
    }
    
    add_filter('em_event_duplicate','my_remove_dates_on_duplicate',10,2);

    While i am at it, why can i not get the results from $EM_Event->duplicate that is set earlier in that function?

    Any help or different direction would be great!

    https://ww.wp.xz.cn/plugins/events-manager/

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    sorry but can I know what do you mean by “why can i not get the results from $EM_Event->duplicate” ? Or did you mean $EM_Event->duplicated ?

    Thread Starter security_man

    (@security_man)

    Yeah, duplicated is what I meant

    Plugin Support angelo_nwl

    (@angelo_nwl)

    this line $EM_Event->duplicated is set as true inside this function or filter and you need to set it to true as well

    Thread Starter security_man

    (@security_man)

    without the filter i am not able to get the results of $EM_Event->duplicated. The filter was the other choice i was trying to get working. It does not seem to change the $EM_Event->event_start_date at all

    so without the function i had above, if i go to the [mydomain.com]/events?action=edit&event_id=[duplicated event id] page, and have echo $EM_Event->duplicated; on that page i get nothing.

    if i hook the function, on events?action=edit&event_id=[duplicated event id] the start date is not null. What am i doing wrong?

    Thread Starter security_man

    (@security_man)

    any ideas on this guys?

    Plugin Support angelo_nwl

    (@angelo_nwl)

    you can try to hook into em_event_duplicate_pre filter instead which runs before saving the event;

    for more info: you can try to check php file under classes/em-event.php

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘remove dates on duplicate’ is closed to new replies.