• Resolved 19fra91

    (@19fra91)


    Hi,
    I need to add some event manually through php and I found this:

    $EM_Event = new EM_Event();
    $EM_Event->event_name = $evt_name;
    $EM_Event->event_start_date = $evt_start_d;
    $EM_Event->event_start_time = $evt_start_t;
    $EM_Event->event_end_date = $evt_end_d;
    $EM_Event->event_end_time = $evt_end_t;
    $EM_Event->start = strtotime($EM_Event->event_start_date." ".$EM_Event->event_start_time);
    
    $EM_Event->end = strtotime($EM_Event->event_end_date." ".$EM_Event->event_end_time);
    $EM_Event->event_all_day = $evt_all_day;
    $EM_Event->recurrence = $evt_rec;
    $EM_Event->recurrence_freq = $evt_rec_freq;
    $EM_Event->recurrence_interval = $evt_rec_int;
    $EM_Event->recurrence_byweekno = $evt_rec_weekno;
    $EM_Event->recurrence_byday = 3;//$evt_rec_byday;
    $EM_Event->recurrence_days = 0;//$evt_rec_days;
    $EM_Event->save();

    This seems that it doesn’t work because I don’t find new events added manually.

    Can someone help me to understand where I wrong?

    Thank you

    https://www.ads-software.com/plugins/events-manager/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Hi,

    How are you using this code?

    Hi, I’m using this code in my function.php file, do you think that problem is the invocation?

    I would like to create some event dinamically passing variables through a function, for example start date, end date and title like this:

    $EM_Event = new EM_Event();
    $EM_Event->event_name = $evt_name;
    $EM_Event->event_start_date = $evt_start_d;
    $EM_Event->event_start_time = $evt_start_t;
    $EM_Event->event_end_date = $evt_end_d;
    $EM_Event->event_end_time = $evt_end_t;
    $EM_Event->save();

    If I get some data like title, start and end date, how can I create manually events? That code doesn’t work form me

    Plugin Support angelo_nwl

    (@angelo_nwl)

    not sure if this will help you out but maybe you can try – https://pastebin.com/3UDjZ8Le

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Adding events through code’ is closed to new replies.