• Roundup WP
  • Products
    • Registrations for the Events Calendar Pro – WordPress Event Registration
      • Buy Now
      • Setup (Pro)
      • Demo
    • Stripe Extension
      • Buy Now
      • Setup
    • Mailchimp Extension
      • Buy Now
      • Setup
    • RTEC Memberships
      • Getting Started
    • RTEC WooCommerce Payments
    • Mollie (iDEAL) Extension
      • Buy Now
      • Setup
    • Discount Codes Extension
      • Buy Now
      • Setup
  • Pricing
  • Features
    • Payments
    • Form Builder
    • Email Messages
    • Registration Management
    • Memberships
    • Event Specific
  • Blog
  • Support
    • FAQs and Troubleshooting
    • Codex
    • Contact Support
  • My Account
  • Get Started

Filter: rtec_fields_attributes

Last updated on February 12, 2015

rtec_fields_attributes is a filter for dynamically altering form fields.

Usage

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

Changelog

Pro
1.0 – introduced

Free
2.0 – introduced

Example: Dynamically Set Checkbox Options Based On Custom Fields

Step 1) Create the custom field and record the label to use later

Step 2) Create a form field of the type checkbox and record the unique key highlighted in the following image

Step 3) Use this code making sure the array keys match (in our example, “time-selection”)

function ru_dynamic_field( $field_attributes ) {

	// only bother trying to change the field if it exists in the form
	if ( isset( $field_attributes['time-selection'] ) ) {

		// get the option that stores The Events Calendar Pro's custom fields data
		$tribe_custom_fields = tribe_get_option( 'custom-fields', false );
		foreach ( $tribe_custom_fields as $custom_field ) {

			// only use the array item if the label matches the custom field you want to use
			if ( $custom_field['label'] === 'Time Selection' ) {
				// create an array of value from the raw values
				$values_array = explode( "\n", $custom_field['values'] );

				// clear out any existing options
				$field_attributes['time-selection']['meta']['options'] = array();

				//$field_attributes['district']['meta']['options'][] array(
					// $label,
					// $value_if_selected,
					// $pre_selected
				// )
				foreach ( $values_array as $value )
				$field_attributes['time-selection']['meta']['options'][] = array(
					trim( $value ),
					trim( $value ),
					false
				);
			}

		}
	}

	return $field_attributes;
}
add_filter( 'rtec_fields_attributes', 'ru_dynamic_field', 10, 1 );

Example: Dynamically Set Field Label Based On Custom Fields for Event

Step 1) Create the custom field and record the “Input field name” to use later

Step 2) Create a custom field, make a note of the “name” that you use.

Step 3) Use this code making sure the array keys and the name of the custom field match (in our example, “dynamic” and “nameoffield”)

function ru_dynamic_custom_field( $field_attributes ) {
	if ( isset( $field_attributes['dynamic'] ) ) {

	    $event_id = get_the_ID();

	    if ( !empty( $event_id ) ) {
	        $event_post_meta = get_post_meta( $event_id, 'nameoffield', true );
		    $field_attributes['dynamic']['label'] = $event_post_meta;
            }

	}


	return $field_attributes;
}
add_filter( 'rtec_fields_attributes', 'ru_dynamic_custom_field', 10, 1 );
Company
  • About
  • Contact
  • Careers
Products
  • Registrations for the Events Calendar
  • Stripe Payments (extension)
  • Mailchimp Email Lists (extension)
  • Event Memberships (extension)
  • WooCommerce Payments (extension)
  • Mollie iDEAL Payments (extension)
  • Discount Codes (extension)
Features
  • Form Builder
  • Event Registration Payments
  • Membership Features
  • Email Messaging
  • Registration Management
  • Event Specific
Resources
  • Support
  • My Account
  • Documentation
  • Pricing
  • Blog
Connect with Us
Follow us on Facebook Contact Us
Copyright © 2026 Roundup WP LLC
Terms & Conditions Privacy Policy Roundup WP Coupon Codes