Filter uncanny-automator

wwlc_filter_first_name_field_form_label

Filters the label for the first name field in the form, allowing customization.

add_filter( 'wwlc_filter_first_name_field_form_label', $callback, 10, 1 );

Description

This filter hook allows you to modify the label for the "First name" field within Wholesale Suite forms. Use it to customize the displayed text, perhaps for localization or to match specific form requirements, before the field label is output.


Usage

add_filter( 'wwlc_filter_first_name_field_form_label', 'your_function_name', 10, 1 );

Return Value

The filtered value.


Examples

/**
 * Filters the label for the 'First Name' field in a form to add a prefix.
 *
 * This function is an example of how to use the 'wwlc_filter_first_name_field_form_label'
 * WordPress filter hook. It demonstrates adding a dynamic prefix to the default
 * 'First name' label, making it more specific or informative depending on the context.
 *
 * @param string $label The default label for the first name field.
 * @return string The modified label for the first name field.
 */
add_filter( 'wwlc_filter_first_name_field_form_label', function( $label ) {
	// Check if a specific user role or context requires a different label prefix.
	// For demonstration purposes, let's assume we want to add "Customer "
	// if the user is logged in and has a specific meta key.
	if ( is_user_logged_in() && get_user_meta( get_current_user_id(), 'is_wholesale_customer', true ) ) {
		return 'Customer ' . $label;
	}

	// If no special condition is met, return the original label.
	return $label;
}, 10, 1 );

Placement

This code should be placed in the functions.php file of your active theme, a custom plugin, or using a code snippets plugin.


Source Code

src/integrations/wholesale-suite/helpers/wholesale-suite-helpers.php:75

$countryList[ $index ]['value'] = $key;
				$countryList[ $index ]['text']  = $value;
				$index ++;
			}
		}
		$fields = array(
			'first_name'        => array(
				'label'       => apply_filters( 'wwlc_filter_first_name_field_form_label', esc_html__( 'First name', 'uncanny-automator' ) ),
				'type'        => 'text',
				'required'    => true,
				'active'      => true,
				'placeholder' => ( get_option( 'wwlc_fields_first_name_field_placeholder' ) ) ? get_option( 'wwlc_fields_first_name_field_placeholder' ) : '',
			),
			'last_name'         => array(
				'label'       => apply_filters( 'wwlc_filter_last_name_field_form_label', esc_html__( 'Last name', 'uncanny-automator' ) ),


Scroll to Top