• Roundup WP
  • Products
    • Registrations for the Events Calendar Pro
      • Buy Now
      • Setup (Pro)
      • Demo
    • Stripe Extension
      • Buy Now
      • Setup
    • Mailchimp Extension
      • Buy Now
      • Setup
    • Mollie (iDEAL) Extension
      • Buy Now
      • Setup
    • Discount Codes Extension
      • Buy Now
      • Setup
  • Support
    • FAQs and Troubleshooting
    • Codex
    • Contact Support
  • My Account
  • Get Pro

Filter: rtec_event_meta

Posted on August 9, 2017

rtec_event_meta is a filter for the event_meta array before it’s returned by the function “rtec_event_meta”. It accepts an argument of the event_meta that has been created based on the event’s settings.

Usage

<?php add_filter( 'rtec_event_meta', 'function_name' ); ?>

Changelog

Pro
1.3 – introduced

Free
2.0 – introduced

Example: No Registration Limit for Logged-in Users

function ru_filter_event_meta( $event_meta ) {

	if ( is_user_logged_in() ) {
		$event_meta['limit_registrations'] = false;
	}

	return $event_meta;
}
add_filter( 'rtec_event_meta', 'ru_filter_event_meta' );

Example: Logged-in users can only register for one event in a category

function ru_one_per_category( $event_meta ) {
    if ( is_admin() ) {
        return $event_meta;
    }

	if ( is_user_logged_in() ) {
        $tax = 'tribe_events_cat';
	    $terms = get_the_terms( $event_meta['post_id'], $tax );
	    if ( empty( $terms ) ) {
	        return $event_meta;
        }
		$post_type = defined('Tribe__Events__Main::POSTTYPE') ? Tribe__Events__Main::POSTTYPE : 'tribe_events';
		$args = array(
			'post_type'      => $post_type,
			'post_status'    => 'publish',
			'posts_per_page' => 50,
			'order'          => 'ASC'
		);

		$ids = array();
	    foreach( $terms as $term ) {
		    $ids[] = $term->term_id;

        }

		$args['tax_query'] = array(
			array(
				'taxonomy' => $tax,
				'field'    => 'id',
				'terms'    => $ids
			)
		);
		$posts = tribe_get_events( $args );
		
		$event_ids = array();
		foreach ( $posts as $post ) {
			$event_ids[] = $post->ID;
        }

		$rtec = RTEC();
		foreach ( $event_ids as $event_id ) {
			$args = array(
				'fields' => array( 'id' ),
				'where' => array(
					array( 'event_id', $event_id, '=', 'int' ),
					array( 'user_id', get_current_user_id(), '=', 'int' )
				),
				'order_by' => 'registration_date'
			);

			$registrations = $rtec->db_frontend->retrieve_entries( $args, true );

			if ( isset( $registrations[0] ) ) {
				$event_meta['registrations_disabled'] = true;
            }
		}

	}

	return $event_meta;
}
add_filter( 'rtec_event_meta', 'ru_one_per_category' );
Registrations for the Events Calendar Pro logo
Make managing your events pain free Our powerful backend features make editing, contacting, and exporting registrants simple. Learn More