• 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_the_attendee_list

Posted on August 9, 2017

rtec_the_attendee_list is an action that runs when the attendee list option is enabled for an event. It accepts one parameter of the $registrants_data which contains the first_name and last_name fields in an associative array by default. This data can be changed with the filter rtec_attendee_list_fields.

Usage

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

Parameters

$registrants_data – (array) Associative array of current registrants that fit the criteria to be included in the attendee list.
$waiting_list Pro Only – (array) Associative array of registrants currently on the waiting list.

Changelog

Pro
1.3 – introduced
2.8 – Added second parameter “$waiting_list”

Free
2.0 – introduced

Example: Change Attendee List to Table

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

function ru_custom_attendee_list( $registrants_data ) {

	$html = '<div class="tribe-events-event-meta rtec-event-meta rtec-attendee-list-meta">';
		$html .= '<h3 class="rtec-section-title">Currently Registered</h3>';
		$html .= '<div style="padding: 0 4%">';

		$html .= '<table>';
		$html .= '<thead>';
			$html .= '<tr>';
				$html .= '<th>First</th>';
				$html .= '<th>Last</th>';
				$html .= '<th>Profession</th>';
				$html .= '<th>Location</th>';
		$html .= '</tr>';
		$html .= '</thead>';
		$html .= '<tbody>';

	        // loops through the $registrants_data and displays the values in their array order
		foreach ( $registrants_data as $registration ) {
			$html .= '<tr>';

			foreach ( $registration as $key => $value ) {
				$html .=  '<td>' . esc_html( $value ) . '</td>';
			}

			$html .=  '</tr>';
		}

		$html .= '</tbody>';
		$html .= '</table>';

		$html .= '</div>';
	$html .= '</div>';

	echo $html;

}
// removes the default attendee list, otherwise you will have two lists
remove_action( 'rtec_the_attendee_list', 'rtec_the_default_attendee_list' );
add_action( 'rtec_the_attendee_list', 'ru_custom_attendee_list' );

function ru_attendee_list_settings_filter( $attendee_list_fields ) {

	// adds custom field data to the $registrants_data for the custom attendee list
	$attendee_list_fields = array( 'first_name', 'last_name', 'custom1', 'custom2' );

	return $attendee_list_fields;
}
add_filter( 'rtec_attendee_list_fields', 'ru_attendee_list_settings_filter', 10, 1 );

Example: Make Name into a Link to the User’s Author Page

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

function ru_custom_list_author_links( $registrants_data ) {
    global $rtec_options;

    $title = isset( $rtec_options['attendee_list_title'] ) ? $rtec_options['attendee_list_title'] : __( 'Currently Registered', 'registrations-for-the-events-calendar' );
    $title = rtec_get_text( $title, __( 'Currently Registered', 'registrations-for-the-events-calendar' ) );
    $return_html = '<div class="tribe-events-event-meta rtec-event-meta rtec-attendee-list-meta"><h3 class="rtec-section-title">' . esc_html( $title ) . '</h3>';

    // to prevent looping through the data twice, two columns are created by alternating appending of qualified registrations
    $column_1_html = '<div class="rtec-attendee-list rtec-list-column-2">';
    $column_2_html = '<div class="rtec-attendee-list rtec-list-column-2">';
    $i = 1;

    foreach ( $registrants_data as $registrant ) {

        $author_url = ! empty( $registrant['user_id'] ) ? get_author_posts_url( $registrant['user_id'] ) : false;

        $before_attendee_name = $author_url ? '<a href="' . $author_url . '">' : ''; // make the attendee's name a link if is a user, otherwise do nothing
        $after_attendee_name = $author_url ? '</a>' : ''; // ending html of the link

        $single_html = '<span class="rtec-attendee">';

        $single_html .= $before_attendee_name; // add the link html here if the attendee is an author

        if ( isset( $registrant['first_name'] ) ) {
            $single_html .= $registrant['first_name'] . ' ';
        }
        if ( isset( $registrant['last_name'] ) ) {
            $single_html .= $registrant['last_name'] . ' ';
        }

        $single_html .= $after_attendee_name; // add the ending link html if attendee is an author

        $single_html .= '</span>';

        if ( $i % 2 === 0 ) {
            $column_2_html .= stripslashes( $single_html );
        } else {
            $column_1_html .= stripslashes( $single_html );
        }
        $i++;

    }

    $column_1_html .= '</div>';
    $column_2_html .= '</div>';
    $return_html .= $column_1_html . $column_2_html;

    $return_html .= '</div>'; // rtec-event-meta

    echo $return_html;
}
add_action( 'rtec_the_attendee_list', 'ru_custom_list_author_links', 10, 1 );
remove_action( 'rtec_the_attendee_list', 'rtec_the_default_attendee_list', 10, 1 );

function ru_attendee_list_settings_filter( $attendee_list_fields ) {

    // adds custom field data to the $registrants_data for the custom attendee list
    $attendee_list_fields = array( 'first_name', 'last_name', 'user_id' );

    return $attendee_list_fields;
}
add_filter( 'rtec_attendee_list_fields', 'ru_attendee_list_settings_filter', 10, 1 );
Registrations for the Events Calendar Pro logo
Learn about the plugin our users are raving about Unmatched customer support from WordPress experts. Learn More