Jump to content
Sign in to follow this  

Buddypress user registration validation not working with custom select query

Recommended Posts

I have created a phone number as Buddypress Profile field. I need to check that no two or more user accounts share the same phone number. My query below is not enforcing the restriction.

I need help to resolve this.

function bp_phone_number_validate() {
global $bp;
global $wpdb;

// check if phone number is in use
$result=$bp->get_var("SELECT COUNT(*) FROM {$bp->profile->wp_bp_xprofile_data} WHERE value = '{$_POST['field_2']}' GROUP BY id;");

if($result > 0){
$bp->signup->errors['field_2'] = __( 'Phone number is already in use.', 'buddypress' );
add_action( 'bp_signup_validate', 'bp_phone_number_validate');


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.