• 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

Action: rtec_before_display_form

Posted on August 9, 2017

rtec_before_display_form is an action that runs before the attendee list and form is displayed. It accepts an argument array of the event_meta. The pro version also includes the user_obj.

Usage

<?php add_action( 'rtec_before_display_form', 'function_name' ); ?>

Changelog

Pro
1.3 – introduced

Free
2.0 – introduced

Example: Add Message

function ru_show_log_in_message( $args ) {

	// if registrations are not disabled and user is not logged in, display message
	if ( ! $args['event_meta']['registrations_disabled'] && ! is_user_logged_in() ) {
		echo '<p class="rtec-success-message tribe-events-notices"><strong>This event is for users only</strong></p>';
	}

}
add_action( 'rtec_before_display_form', 'ru_show_log_in_message' );

Example: Add Message and Registrations for Members Only

Note: This requires use of an additional filter “rtec_event_meta”

function ru_filter_event_meta( $event_meta ) {

	if ( ! is_user_logged_in() ) {
		$event_meta['registrations_disabled'] = true;
	}

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

function ru_show_log_in_message( $args ) {

	if ( $args['event_meta']['registrations_disabled'] && ! is_user_logged_in() ) {
		echo '<p class="rtec-success-message tribe-events-notices"><strong>Please log in to register</strong></p>';
	}

}
add_action( 'rtec_before_display_form', 'ru_show_log_in_message' );

Example: Open Registration “X” Days Before the Start Date

Note: This requires use of an additional filter “rtec_event_meta”

function ru_open_date( $event_meta ) {

	// set registration open on date 7 days before
	$days_before_start_date = 7;
	$registration_opens_on_timestamp = strtotime( $event_meta['start_date'] ) - rtec_get_time_zone_offset() - DAY_IN_SECONDS * $days_before_start_date;

	// if not the admin area and the registration open on date has passed
	if ( !is_admin() && $registration_opens_on_timestamp > time() ) {
		$event_meta['registrations_disabled'] = true;
	}

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

function ru_not_open_message( $args ) {

	$registration_opens_on_timestamp = strtotime( $args['event_meta']['start_date'] ) - rtec_get_time_zone_offset() - DAY_IN_SECONDS * 2;

	if ( $registration_opens_on_timestamp > time() ) {
		echo '<p class="rtec-success-message tribe-events-notices">Registration will open ' . date_i18n( rtec_get_date_time_format(), $registration_opens_on_timestamp + rtec_get_time_zone_offset() ) . '</p>';
	}

}
add_action( 'rtec_before_display_form', 'ru_not_open_message' );
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