Skip to:
Content
Pages
Categories
Search
Top
Bottom

I want to change label’s required word to * in registration form


  • hemanttechno
    Participant

    @hemanttechno

    Hello There,

    I’m new to buddypress & trying to change label “required” word to “*” buddypress new user registration form. For this I have modified wp-content/plugins/buddypress/bp-themes/bp-default/registration/register.php but unfortunately no changes found in my registration form. I’m using ‘Bakes And Cakes’ wordpress free theme as well.

    I have replaced required to * please find as below:

    <div class=”register-section” id=”basic-details-section”>

    <?php /***** Basic Account Details ******/ ?>

    <h4><?php _e( ‘Account Details’, ‘buddypress’ ); ?></h4>

    <label for=”signup_username”><?php _e( ‘Username’, ‘buddypress’ ); ?> <?php _e( ‘*’, ‘buddypress’ ); ?></label>
    <?php do_action( ‘bp_signup_username_errors’ ); ?>
    <input type=”text” name=”signup_username” id=”signup_username” value=”<?php bp_signup_username_value(); ?>” />

    <label for=”signup_email”><?php _e( ‘Email Address’, ‘buddypress’ ); ?> <?php _e( ‘*’, ‘buddypress’ ); ?></label>
    <?php do_action( ‘bp_signup_email_errors’ ); ?>
    <input type=”text” name=”signup_email” id=”signup_email” value=”<?php bp_signup_email_value(); ?>” />

    <label for=”signup_password”><?php _e( ‘Choose a Password’, ‘buddypress’ ); ?> <?php _e( ‘*’, ‘buddypress’ ); ?></label>
    <?php do_action( ‘bp_signup_password_errors’ ); ?>
    <input type=”password” name=”signup_password” id=”signup_password” value=”” />

    <label for=”signup_password_confirm”><?php _e( ‘Confirm Password’, ‘buddypress’ ); ?> <?php _e( ‘*’, ‘buddypress’ ); ?></label>
    <?php do_action( ‘bp_signup_password_confirm_errors’ ); ?>
    <input type=”password” name=”signup_password_confirm” id=”signup_password_confirm” value=”” />

    <?php do_action( ‘bp_account_details_fields’ ); ?>

    </div><!– #basic-details-section –>

    Can anyone please guide me in right direction how to do so?

Viewing 6 replies - 1 through 6 (of 6 total)

  • Paul
    Participant

    @paulpdb

    This is the method I use

    Customizing Labels, Messages, and URLs

    using loco translate plugin

    https://wordpress.org/plugins/loco-translate/


    hemanttechno
    Participant

    @hemanttechno

    Hello Paul,

    Thankyou for answering!

    I have installed loco translate plugin. I’m trying ‘Username required – Username *’ But Still unable to understand how to change these label by using this plugin.

    please let me know the steps if you can?

    Thanks


    hemanttechno
    Participant

    @hemanttechno

    Thanks I have done it.


    alexalexalex09
    Participant

    @alexalexalex09

    I know this is an old thread, but for those who are (like me) interested and googling this, here’s a quick solution that requires no language file editing.

    Just add the following code to bp-custom.php (which, if it doesn’t exist, you’ll need to create in wpcontent/plugins).

    
    function bp_change_required_label($translated_string, $field_id) {
    		return '*';		
    }
    add_filter('bp_get_the_profile_field_required_label', 'bp_change_required_label', 10, 2);
    

    This function hooks into the function bp_get_the_profile_field_required_label() in buddypress/bp-xprofile/bp-xprofile-template using the supplied filter. It takes the translated “(required)” string and replaces it with “*”. which will also remove any translation – but that should be acceptable for a symbol in most cases.


    alexalexalex09
    Participant

    @alexalexalex09

    Whoops, I forgot instructions on how to change the account details fields. Here, I updated it:

    To change the text on the regular (Account Details) fields, make a copy of wpcontent/plugins/buddypress/bp-templates/bp-legacy/buddypress/members/register.php and place it in themes/your-child-theme/buddypress/members (a folder which you will have to create).

    Then, open that file and replace every instance of <?php _e( '(required)', 'buddypress' ); ?> with your asterisk (*).

    Then, to change the text on profile fields (Profile Details), just add the following code to bp-custom.php (which, if it doesn’t exist, you’ll need to create in wpcontent/plugins).

    
    function bp_change_required_label($translated_string, $field_id) {
    		return '*';		
    }
    add_filter('bp_get_the_profile_field_required_label', 'bp_change_required_label', 10, 2);
    

    This function hooks into the function bp_get_the_profile_field_required_label() in buddypress/bp-xprofile/bp-xprofile-template using the supplied filter. It takes the translated “(required)” string and replaces it with “*”. which will also remove any translation – but that should be acceptable for a symbol in most cases.


    Venutius
    Moderator

    @venutius

    Thanks Alex!

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar