This topic has 1 reply, 2 voices, and was last updated 8 years by sharmstr.

  • Author
  • #113758
     doyoonee
    Participant

    Hi,

    I”m making an Action hook after user registration.

    And I want to check one the profile field and if the data is not valid, I want to delete the user…

    See the code script below….

    I tried many many times… but it does not work… I can’t find the reason…

    Can you check what’s wrong in the code….

     

    //add_action(‘user_register’,’talk25_user_creation’,100000,1);

    add_action(‘bp_core_signup_user’,’talk25_user_creation’,10,1);

    function talk25_user_creation($user_id) {

    global $wpdb;

    //Check one of Registration field. Compare the first 3 digits to verify the user. Or delete the user

    $user_cell = xprofile_get_field_data(3,$user_id);

    $check_cell = substr($user_cell,0,3);

    if($check_cell != “010” && $check_cell !=”011″ && $check_cell != “016” && $check_cell != “017” && $check_cell != “019”) {

    if ( !function_exists( ‘wp_delete_user’ ) ) {

    require_once(ABSPATH.’wp-admin/includes/user.php’ );

    }

    wp_delete_user($user_id);

    //$res = $wpdb->query( $wpdb->prepare(“delete from wp_tk_users where ID = ‘%d'”,$user_id) );

    //$wpdb->query( $wpdb->prepare(“delete from $wpdb->bp_xprofile_data where user_id = %d”,$user_id) );

    return;

    }

    }

     

    #113881
     sharmstr
    Moderator

    Ask on the buddypress forum. This isn’t related to Kleo.

    With that said, without elaborating on “its not working”, its hard to help. It could be that your action is firing before the bp_core_signup_user action (xprofile_sync_wp_profile) that saves the xprofile fileds to the db. Again, hard to say without knowing where things “aren’t working”. Also, if it were me, I’d look into adding jquery form validation to validate that field before the user is created instead of deleting the user after the fact.

    Thats the most I can offer in terms of support.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 2 posts - 1 through 2 (of 2 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?