BuddyDev

Search

[Resolved] How to use bp hooks?

  • Participant
    Level: Initiated
    Posts: 2
    savant on #43141

    How to customise register.php?

    I have a theme child of buddyboss. And in the functions.php, I have this code:

    
    add_filter('bp_members_signup_error_message', 'function_voornaam', 10, 1);
    function function_voornaam($value,  $fieldname)
    {
        if ($fieldname == 'field_1') {
            return  $value = '<style>{font-family:bold}</style>  you have to enter name.';
        }
    
        return $value;
    }
    
    

    So that by voornaam the text: This is a required field. will be replaced by the you have to enter name. But the text doesn’t change.

    This is a image:

    https://postimg.cc/pmJjksp6

    What I have to change?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #43152

    Hi,
    That’s not the right way to do it as the $fieldname is not available with that hook.

    here is the code you may use

    
    add_action( 'bp_signup_validate', function () {
    
    	$bp = buddypress();
    	if ( ! $bp->signup->errors ) {
    		return;
    	}
    
    	if ( isset( $bp->signup->errors['field_1'] ) ) {
    		$bp->signup->errors['field_1'] = sprintf(
    			'<div class="bp-messages bp-feedback error">
    								<p>%s</p>
    							</div>',
    			'You have to enter name.' );
    
    	}
    } );
    
    

    Regards
    Brajesh

  • Participant
    Level: Initiated
    Posts: 2
    savant on #43154

    Whoooo. Thank you so much!!! I was bussy for days with it. Thank you!

  • Participant
    Level: Initiated
    Posts: 2
    savant on #43155

    And the text error message is appearing above the input field.

    But how to show the error text message under the input field?

  • Keymaster
    (BuddyDev Team)
    Posts: 24706
    Brajesh Singh on #43166

    You are welcome.

    As of moving the error message below the input, sorry, there is no direct way. I will suggest contacting BuddyBoss to see if they have some way.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: resolved