Jump to content

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');

 

Link to post
Share on other sites
This thread is more than a year old.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.