Home › Forums › Calendar Products › Events Calendar PRO › create a recurring event in PHP
- This topic has 7 replies, 2 voices, and was last updated 11 years, 10 months ago by
Barry.
-
AuthorPosts
-
June 26, 2014 at 3:50 am #252470
bastienliutkus
Participanthello 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..
June 26, 2014 at 7:43 am #252813bastienliutkus
Participantso 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
June 26, 2014 at 7:44 am #252816bastienliutkus
Participantcause i repeat : my goal is to do a RECURRING event each month (for instance) until a date
June 26, 2014 at 8:03 am #252862bastienliutkus
Participantchanging the “is_recurring” by “false”, true, “true” or 1 didn’t change anything
June 26, 2014 at 1:51 pm #253509Barry
MemberHi!
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!
June 27, 2014 at 12:53 am #254571bastienliutkus
Participanthi 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.
June 27, 2014 at 1:01 am #254590bastienliutkus
Participantsorry, made mistakes on the pastbin, use this one instead http://pastebin.com/2n6RUgf1
June 27, 2014 at 1:14 pm #255834Barry
MemberOK, well I think at least two things need to happen:
- 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
- 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 🙂
-
AuthorPosts
- The topic ‘create a recurring event in PHP’ is closed to new replies.
