Take a look at plugins/buddypress/bp-members/screens/register.php
this is loaded when the register form is submitted. There’s a hook in there do_action( 'bp_signup_validate' );
which you could use to implement your own validation.
In there you can set `$bp->signup->errors for the error you want to display if the validation fails for that field.
Hello, while I’ve gotten the site to fail a registration with an incorrect number using what you suggested above, it doesn’t display any error message of sorts. My line is: $bp->signup->errors['invalid_number'] = __( 'Please enter a valid phone number', 'buddypress' );
This is in my bp-custom.php class, in the function that gets added to the hook bp_signup_validate, when an incorrect phone number is determined. The site properly fails a registration with an incorrect number, while allowing registration with a correct one, but it doesn’t display any error pop up at all, even though I included an error message of sorts with the latter half of the line. Is this a code issue, or could this potentially be a theme issue? I’m using the Spacious theme if this helps
do I have to use errors['invalid_number']
anywhere at all within any of the scripts?
As far as I can see that should be all you need to do, The register.php screen runs a function to display the error that you have input in line 149.
Where is it supposed to display the message?
So do you have any recommendations or advice?
invalid_number is an error that I created in the bp-custom.php class, not a built in one, do I have to do anything to have it show up as a popup or to move it to display over the text field?
After some experimentation, it seems the line add_action( 'bp_' . $fieldname . '_errors', function() use ( $error_message ) {echo apply_filters( 'bp_members_signup_error_message', "<div class=\"error\">" . $error_message . "</div>" );} );
gets called with both the phone number error, or any other default one, such as a mismatch between passwords.
As such, this seems to look like the function in question. Is there any reason it would run and display a message for default errors, but do nothing visually for my custom one?