Filter
uncanny-automator
wwlc_filter_phone_field_form_label
Filters the label for the phone field within Wholesale Lead Capture forms.
add_filter( 'wwlc_filter_phone_field_form_label', $callback, 10, 1 );
Description
This filter hook allows developers to modify the label text for the phone number field in Wholesale Suite forms. It fires when the form is being rendered, providing an opportunity to customize the displayed label, perhaps for localization or specific branding needs. Developers can return a new string to replace the default "Phone."
Usage
add_filter( 'wwlc_filter_phone_field_form_label', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Example of filtering the 'wwlc_filter_phone_field_form_label' hook.
* This function will change the default label for the phone field if a specific option is set.
*
* @param string $label The current label for the phone field.
* @return string The modified or original label for the phone field.
*/
add_filter( 'wwlc_filter_phone_field_form_label', function ( $label ) {
// Check if the option to use a custom label for the phone field is enabled.
$use_custom_label = get_option( 'wwlc_use_custom_phone_label' );
if ( $use_custom_label === 'yes' ) {
// Retrieve the custom phone label from options.
$custom_label = get_option( 'wwlc_custom_phone_label_text' );
// If a custom label is set, use it, otherwise fall back to the default.
if ( ! empty( $custom_label ) ) {
// Sanitize the custom label before returning.
return sanitize_text_field( $custom_label );
}
}
// Return the original label if no custom label is used or set.
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:89
'label' => apply_filters( 'wwlc_filter_last_name_field_form_label', esc_html__( 'Last name', 'uncanny-automator' ) ),
'type' => 'text',
'required' => true,
'active' => true,
'placeholder' => ( get_option( 'wwlc_fields_last_name_field_placeholder' ) ) ? get_option( 'wwlc_fields_last_name_field_placeholder' ) : '',
),
'wwlc_phone' => array(
'label' => apply_filters( 'wwlc_filter_phone_field_form_label', esc_html__( 'Phone', 'uncanny-automator' ) ),
'type' => 'phone',
'required' => ( get_option( 'wwlc_fields_require_phone_field' ) == 'yes' ) ? true : false,
'active' => true,
'placeholder' => ( get_option( 'wwlc_fields_phone_field_placeholder' ) ) ? get_option( 'wwlc_fields_phone_field_placeholder' ) : '',
),
'user_email' => array(
'label' => apply_filters( 'wwlc_filter_email_field_form_label', esc_html__( 'Email', 'uncanny-automator' ) ),