create a recurring event in PHP

Home Forums Calendar Products Events Calendar PRO create a recurring event in PHP

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #252470
    bastienliutkus
    Participant

    hello I can’t find any doc niether a snippet/tutorial to create an event in PHP (ie the equivalent of https://theeventscalendar.com/support/documentation/events-calendar-pro-new-user-primer/#recur but coding it). From what i understand there is a process of creating an event from a “tribe_events” post_id but can’t understand more than that.

    my goal is : when a page is created i have to create automatically some reccurring events. so i need to do it by code. Please give answers..

    #252813
    bastienliutkus
    Participant

    so inspiring me by https://github.com/moderntribe/the-events-calendar/blob/develop/tests/phpunit/Tribe_Event_Creation_Test.php

    i managed to create a non recurring event doing
    $eventSettings = array(
    ….
    “is_recurring” =>”yes”,
    “recurrence[type]” =>”Every+Month”,
    “recurrence[end-type]” =>”On”,
    “recurrence[end]” =>”2014-06-29″,
    “recurrence[end-count]” =>”1″,
    “recurrence[custom-type]” =>”Daily”,
    “recurrence[custom-interval]” =>””,
    “recurrence[custom-type-text]” =>””,
    “recurrence[occurrence-count-text]” =>”month”,
    “recurrence[custom-month-number]” =>”First”,
    “recurrence[custom-month-day]” =>”1″,
    “recurrence[custom-year-month-number]” =>”1″,
    “recurrence[custom-year-month-day]” =>”1″,
    “recurrence[recurrence-description]” =>””,
    );
    $event_id = TribeEventsAPI::createEvent($eventSettings);

    i don’t see where i did it bad, if you could help… Thx

    #252816
    bastienliutkus
    Participant

    cause i repeat : my goal is to do a RECURRING event each month (for instance) until a date

    #252862
    bastienliutkus
    Participant

    changing the “is_recurring” by “false”, true, “true” or 1 didn’t change anything

    #253509
    Barry
    Member

    Hi!

    We can’t always go into depth with custom dev questions like this, but we’d be happy to point you in the right direction if we can. Can I see the complete snippet (and can you share it via Pastebin or Gist, rather than posting in the forum)? What action are you calling it on, or else where  is your code located?

    Thanks!

    #254571
    bastienliutkus
    Participant

    hi there thx for answer, here is my pastebin link : http://pastebin.com/VYQLNqZL
    as you see i do a add_action(“save_post” and in my function i create an event, this code is of course in my functions.php in the theme. I suppose i don’t use correct settings. Feel free to modify the pastebin or so. Hope you can answer today so i can continue the work during the week end.

    all the best.

    #254590
    bastienliutkus
    Participant

    sorry, made mistakes on the pastbin, use this one instead http://pastebin.com/2n6RUgf1

    #255834
    Barry
    Member

    OK, well I think at least two things need to happen:

    1. It looks like you may have got started by looking at the form data for recurrence in the event editor. In this case, though, you’re communicating directly with the API – the data isn’t being transmitted by HTTP – so rather than pass in values with keys like recurrence[type] and so on, you should probably pass in an actual array
    2. Don’t do anything too early! save_post should be fine, but in essence you need to make this fire after the TribeEventsRecurrenceMeta object sets up its own action and filter callbacks

    From here on I’m afraid we’ll need to leave you to investigate – but I do wish you luck – it’s great to see interesting stuff like this being built 🙂

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘create a recurring event in PHP’ is closed to new replies.