Skip to content

Instantly share code, notes, and snippets.

View chikaibeneme's full-sized avatar
:atom:
Focusing

Chika Ibeneme chikaibeneme

:atom:
Focusing
  • iKaDigital
  • Jamaica
View GitHub Profile
@chikaibeneme
chikaibeneme / functions.php
Created August 4, 2021 04:21
functions.php
function tec_1163154_dequeue_gmaps_script() {
if ( ! class_exists( 'Tribe__Events__Main' ) ) {
return false;
}
$tecmain = Tribe__Events__Main::instance();
if (
// https://developer.wordpress.org/reference/functions/is_post_type_archive/
/**
* Automatically set event categories as post categories for the Events Calendar.
*/
function set_event_categories_as_post_categories( $post_id ) {
// Check if the post is an event post type
if ( 'tribe_events' === get_post_type( $post_id ) ) {
// Get the event categories
$event_categories = wp_get_post_terms( $post_id, 'tribe_events_cat', array( 'fields' => 'names' ) );
// Set event categories as post categories
/*The Tribe Events Calendar plugin for WordPress provides several functions to retrieve information about events and their tickets. While there isn't a specific function to differentiate between paid/free tickets and RSVPs, you can use a combination of functions to achieve the desired result.
To determine if an event has tickets or is only based on RSVP, you can use the following approach:
Use the tribe_get_event_meta() function to retrieve the event's ticketing meta information. This function returns an array containing various details about the event, including ticketing information.
Check if the event has any tickets by accessing the 'tribe_tickets' key in the returned array. If it exists and is not empty, it indicates that the event has tickets.
If the event has tickets, you can further examine the ticket types to determine if they are paid or free. You can use the tribe_get_ticket_types() function to retrieve an array of ticket types for the event.
Iterate through the ticket types array and check the
@chikaibeneme
chikaibeneme / Add category to all events.php
Created January 11, 2024 05:28
To add a category to all events using The Events Calendar in WordPress
// Add category to all events
function add_category_to_all_events() {
// Get all events
$events = get_posts(array(
'post_type' => 'tribe_events',
'posts_per_page' => -1, // Get all events
));
// Check if events are found
if ($events) {
@chikaibeneme
chikaibeneme / Example for adding event data to WooCommerce checkout for Events Calendar tickets.php
Created January 18, 2024 05:41
Example for adding event data to WooCommerce checkout for Events Calendar tickets.php
/**
* Example for adding event data to WooCommerce checkout for Events Calendar tickets.
*
*/
add_filter('woocommerce_cart_item_name', 'woocommerce_cart_item_name_event_title', 10, 3);
function woocommerce_cart_item_name_event_title($title, $values, $cart_item_key) {
// Check if the product is an Events Calendar ticket
$product_id = isset($values['product_id']) ? $values['product_id'] : null;
@chikaibeneme
chikaibeneme / registration_fields.php
Last active November 1, 2024 06:09
Change the name of the registration fields
add_filter( 'tribe_tickets_plus_attendee_registration_iac_fields', 'modify_attendee_fields' );
function modify_attendee_fields( $fields ) {
// Check if 'Name' field exists before modifying
if ( isset( $fields['name'] ) ) {
$fields['name']['label'] = 'First Name'; // Change label to 'First Name'
}
// Optionally, you can add other modifications here
// For example, changing placeholder text:
@chikaibeneme
chikaibeneme / registration_label_change.php
Last active November 1, 2024 06:11
Change the attendee registration default field name.
<?php //Do not copy this line
add_filter( 'tribe_tickets_plus_attendee_registration_iac_fields', 'modify_attendee_fields' );
function modify_attendee_fields( $fields ) {
// Check if 'Name' field exists before modifying
if ( isset( $fields['name'] ) ) {
$fields['name']['label'] = 'First Name'; // Change label to 'First Name'
}
// Optionally, you can add other modifications here
@chikaibeneme
chikaibeneme / Add Virtual Meeting URL and Organizer Link to Event Description in iCal Feed.php
Created November 13, 2024 21:21
Add Virtual Meeting URL and Organizer Link to Event Description in iCal Feed.php
@chikaibeneme
chikaibeneme / tec-tickets-email-rsvp-alternate-bcc.php
Created November 29, 2024 04:45
Add a custom BCC for the RSVP email (All ticket emails)
<?php
//* Do NOT include the opening php tag
/**
* If you want the BCC added to all ticket-related emails, regardless of type.
* Useful for broader email handling, especially if your organization manages multiple ticket types.
*/
add_filter( 'tribe_tickets_email_headers', function( $headers, $ticket_id ) {