Filter
uncanny-automator
wwlc_filter_city_field_form_placeholder
Filters the placeholder text for the city field in wholesale registration forms.
add_filter( 'wwlc_filter_city_field_form_placeholder', $callback, 10, 1 );
Description
Filters the placeholder text for the City field in forms generated by Wholesale Suite. Developers can use this hook to customize the default placeholder, which is retrieved from the WordPress option `wwlc_fields_city_placeholder` or defaults to an empty string. This allows for dynamic or localized city field hints.
Usage
add_filter( 'wwlc_filter_city_field_form_placeholder', 'your_function_name', 10, 1 );
Return Value
The filtered value.
Examples
/**
* Filters the placeholder text for the City field in the registration form.
*
* This example allows you to dynamically change the placeholder text based on
* the user's role or other conditions. Here, we'll append a note if the user
* is an administrator.
*
* @param string $placeholder The current placeholder text for the city field.
* @return string The modified placeholder text.
*/
add_filter( 'wwlc_filter_city_field_form_placeholder', 'my_custom_city_placeholder', 10, 1 );
function my_custom_city_placeholder( $placeholder ) {
// Check if the current user is an administrator
if ( current_user_can( 'manage_options' ) ) {
// Append a note to the placeholder for administrators
return $placeholder . ' (Admin Override)';
}
// Otherwise, return the original placeholder
return $placeholder;
}
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:142
'placeholder' => apply_filters( 'wwlc_filter_address2_field_form_placeholder', get_option( 'wwlc_fields_address2_placeholder', '' ) ),
),
'wwlc_city' => array(
'label' => apply_filters( 'wwlc_filter_city_field_form_label', esc_html__( 'City', 'uncanny-automator' ) ),
'type' => 'text',
'required' => ( get_option( 'wwlc_fields_require_address_field' ) == 'yes' ) ? true : false,
'active' => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
'placeholder' => apply_filters( 'wwlc_filter_city_field_form_placeholder', get_option( 'wwlc_fields_city_placeholder', '' ) ),
),
'wwlc_state' => array(
'label' => apply_filters( 'wwlc_filter_state_field_form_label', esc_html__( 'State', 'uncanny-automator' ) ),
'type' => 'text',
'required' => ( get_option( 'wwlc_fields_require_address_field' ) == 'yes' ) ? true : false,
'active' => ( get_option( 'wwlc_fields_activate_address_field' ) == 'yes' ) ? true : false,
'placeholder' => apply_filters( 'wwlc_filter_state_field_form_placeholder', get_option( 'wwlc_fields_state_placeholder', '' ) ),