Jump to content


Photo

Buddypress user registration validation not working with custom select query

buddypress

  • Please log in to reply
No replies to this topic

#1 terungwa

terungwa
  • Members
  • PipPipPip
  • Advanced Member
  • 90 posts

Posted 20 March 2017 - 02:46 PM

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

 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users