Introduction
Would you like to change sublabels on your form Email fields? You can change the sublabels that appear below the email on your form.
In WPForms when you enable the Email Confirmation box on the Email form field, sublabels are automatically added below the Email fields with default text. In this tutorial, we’ll show you the basics of how you can change the sublabels using a PHP code snippet.
Creating the form
First, we’ll create a new form and add our form fields. When adding the Email field, be sure to toggle the Enable Email Confirmation.
If you need any help in creating your form, please review this documentation.
Adding the snippet
It’s now time to add the snippet to your site.
If you’re not sure where or how to add snippets to your site, please review this tutorial.
/** * Customize email field properties. * * @link https://wpforms.com/developers/how-to-change-sublabels-for-the-email-field/ */ function wpf_dev_email_field_properties( $properties, $field, $form_data ) { // Change sublabel values $properties[ 'inputs' ][ 'primary' ][ 'sublabel' ][ 'value' ] = __( 'Enter Your Email', 'plugin-domain' ); $properties[ 'inputs' ][ 'secondary' ][ 'sublabel' ][ 'value' ] = __( 'To confirm, re-enter your email address here', 'plugin-domain' ); return $properties; } add_filter( 'wpforms_field_properties_email' , 'wpf_dev_email_field_properties', 10, 3 );
And that’s all you need to change the sublabels on the Email field! Would you like to change the sublabels for the Name field as well? Take a look at our article on How to Change Sublabels for the Name Field.
Related
Filter Reference: wpforms_field_properties