$args = [
'title' => 'Cool Event with Cost',
'description' => 'This is showing that the description can be a long string and...',
'start_date' => date( 'Y-m-d H:i:s' ),
'end_date' => date( 'Y-m-d H:i:s', strtotime( '+2 hours' ) ),
'url' => 'https://example-external-website.com',
'cost' => 15,
'currency_symbol' => '€',
'currency_position' => 'prefix',
'status' => 'publish',
'category' => [ 4 ],
];
$result = tribe_events()->set_args( $args )->create();
My amount of grey hair is increassing ;). Can anybody help?
]]>I am currently using the save_post_tribe_events hook when creating an event in the wordpress page to retrieve it and do something with it. I want to retrieve that event with the ORM like this:
add_action('save_post_tribe_events', 'get_event');
function get_event($event_id) {
$new_event = tribe_events()->by('id', $event_id)->first();
}
The problem is that returns null and I think that is because the event hasn’t been stored yet on the db when that hook fires. I could use the tribe_get_event() function, but that doesn’t give me all the info the ORM gives me, like the venue object or the organizer object
What can I do?
Thank you for your time
]]>I am creating an event with the ORM like this:
$new_event = tribe_events()->set_args($event)->create();
// Set meta field to the event
add_post_meta($new_event->ID, '_meta_field', $meta_field);
After that, I need to get the value of this meta field when the event is created and I do this:
add_action('save_post_tribe_events', 'get_meta_field');
function get_meta_field($event_id) {
$meta_field = get_post_meta($event_id, '_meta_field', true)
}
But I get nothing when the event is published. But, when I delete the event, the hook also fires and this time I have the meta field value. The thing is, I need the data when the event is published.
I tried this with other hooks like wp_insert_post or wp_after_insert_post but to no avail. I also tried to get $_POST[‘_meta_field’], but also nothing.
What can I do?
Thank you
]]>Otherwise, I really would appreciate and be very grateful for some assistance with this. I removed a bunch of the code, so the logic below won’t make sense, but the gist should be there. The get_venue function passes a string with the name of the location and then return the full object of the venue post. I have tried just returning the ID, the full object, and just the string. None of it works.
Thank in advance
function get_venue($location){
$location = explode('\,', $location)[0];
$venues = json_decode(json_encode(tribe_get_venues()), true);
foreach ($venues as $v):
echo $v['post_title'] . PHP_EOL;
if ($v['post_title'] == $location):
$venue = $v;
break;
endif;
endforeach;
return $venue;
/* Example of returned
(
[ID] => 404
[post_author] => 1
[post_date] => 2020-04-07 08:32:29
[post_date_gmt] => 2020-04-07 08:32:29
[post_content] =>
[post_title] => District Middle School
[post_excerpt] =>
[post_status] => publish
[comment_status] => closed
[ping_status] => closed
[post_password] =>
[post_name] => city-hall
[to_ping] =>
[pinged] =>
[post_modified] => 2023-04-28 12:41:50
[post_modified_gmt] => 2023-04-28 12:41:50
[post_content_filtered] =>
[post_parent] => 0
[guid] => https://intranet.domain.org/?post_type=tribe_venue&p=404
[menu_order] => 0
[post_type] => tribe_venue
[post_mime_type] =>
[comment_count] => 0
[filter] => raw
)
*/
}
function create_event($e){
$event = array(
'post_title' => $e['post_title'],
'post_content' => $e['post_content'],
'post_status' => 'publish',
'post_author' => 1,
'EventStartDate' => $e['EventStartDate'],
'EventEndDate' => $e['EventEndDate'],
'EventStartHour' => $e['EventStartHour'],
'EventStartMinute' => $e['EventStartMinute'],
'EventStartMeridian' => $e['EventStartMeridian'],
'EventEndHour' => $e['EventEndHour'],
'EventEndMinute' => $e['EventEndMinute'],
'EventEndMeridian' => $e['EventEndMeridian'],
'Venue' => $e['venue']
/*,
'Organizer' => array(
'Organizer' => 'Organizer Name',
'Email' => '[email protected]'
)*/
);
$result = tribe_create_event( $event );
update_post_meta($result, '_thumbnail_id', '8671');
return $result;
}
$e['venue'] = get_venue($e['location']);
create_event($e);
//// Example $e array below. Using just the Venue ID///
(
[post_title] => Test Event 2
[post_content] => description
[post_status] => publish
[post_author] => 1
[EventStartDate] => 2023-05-15
[EventEndDate] => 2023-05-15
[EventStartHour] => 09
[EventStartMinute] => 00
[EventStartMeridian] => AM
[EventEndHour] => 10
[EventEndMinute] => 00
[EventEndMeridian] => AM
[Venue] => 404
)
]]>I went to create a new event today and where has everything gone?
Everything to create an event was on one page – simples. But now it seems that I have to select different pages (screen) for organiser, location – so many extra, unnecessary clicks.
Is there a setting I’m missing to get everything for an event on the one page, as it used to be? If not, is there any way to go back to the previous version as it was so much easier to use. And more logical.
Thanks,
A beekeeper who also tries to run a website.
]]>I would like to require a name, and an email address.
looking at the PHP file I see Name Phone and Email fields but they’re not showing on the front end and I can’t find the setting to show those fields.
]]>I can’t seem to find where to change the following form labels?
– Bookings | would like it to be: Sponsorship/Tickets
– Ticket Type | would like it to be: Sponsorship Level
– Spaces | would like it to be: Number
Thanks in advance for any guidance with this.
]]>