Filter
uncanny-automator
wwlc_filter_last_name_field_form_label
Filters the label for the last name field on forms, allowing customization of this default text.
add_filter( 'wwlc_filter_last_name_field_form_label', $callback, 10, 1 );
Description
This filter allows developers to modify the default "Last name" label for fields in forms integrated with Wholesale Suite. Use it to localize or customize the label text before it's displayed to users, ensuring accurate and user-friendly form presentation.
Usage
add_filter( 'wwlc_filter_last_name_field_form_label', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
<?php
/**
* Example of filtering the 'wwlc_filter_last_name_field_form_label' hook.
* This function demonstrates how to change the default "Last name" label
* for the last name field in a form, for instance, to "Surname" or to add a prefix.
*
* @param string $label The default label for the last name field.
* @return string The modified label for the last name field.
*/
add_filter( 'wwlc_filter_last_name_field_form_label', 'my_custom_wwlc_last_name_label', 10, 1 );
function my_custom_wwlc_last_name_label( $label ) {
// Example 1: Change the label to "Surname"
// return esc_html__( 'Surname', 'uncanny-automator' );
// Example 2: Add a prefix to the label, e.g., "Your Last Name"
// return 'Your ' . $label;
// Example 3: Conditionally change the label based on user role or other conditions.
// For this example, let's assume we want to change it for administrators.
if ( current_user_can( 'manage_options' ) ) {
return esc_html__( 'Family Name', 'uncanny-automator' );
}
// If no specific condition is met, return the original label.
return $label;
}
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:82
'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' ) ),
'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' ) ),