Purpose

Add or modify options for a dynamic data field programmatically. This filter allows developers to populate a field’s options dynamically based on the field’s identifier or other criteria.

Usage

add_filter( "wr_form_dynamic_data_load_options_by_filter", array( $this, "add_information" ), 10, 2 );

Parameters

  • $options (array): The current options available for the dynamic data field.
  • $identifier (string): The identifier of the field where options are being loaded.

Use Case

This functionality is useful when:

  • You need to populate dropdowns or other dynamic fields with data sourced programmatically.
  • The options for a field depend on external conditions, such as database queries, user roles, or contextual settings.

Implementation Example

The following example adds custom options (Apple and Banana) to a dynamic field identified by form_field_identifier:

add_filter( "wr_form_dynamic_data_load_options_by_filter", array( $this, "add_information" ), 10, 2 );
 
public function add_information( $options, $identifier ) {
	if ( $identifier == 'form_field_identifier' ) {
		$options[] = array( 'value' => 1, 'text' => 'Apple' );
		$options[] = array( 'value' => 2, 'text' => 'Banana' );
	}
	return $options;
}