Skip to:
Content
Pages
Categories
Search
Top
Bottom

bp_core_validate_email_address doesn’t check signups table

  • @baldgoat

    Participant

    bp_core_validate_email_address does not check the signups table to see if a pending/inactive signup has a duplicate email.

    So, if BP_SIGNUPS_SKIP_USER_CREATION is set to true in the wp-config, a user could inadvertently create several signups with the same email address. Which causes lots of DB clutter and has potential to create other problems.

Viewing 4 replies - 1 through 4 (of 4 total)
  • @shanebp

    Moderator

    bp_core_validate_email_address uses the WP function email_exists.
    So perhaps that WP function should check the signups table.

    You can open a ticket here and a decision will be made as to whether it should actually be a WP ticket:
    https://buddypress.trac.wordpress.org/newticket
    Use the same suer / pw you use for these forums.

    @baldgoat

    Participant

    Thanks ticket has been opened.

    For anyone interested, here’s the filter I added to my functions file…

    add_filter('bp_core_validate_user_signup', 'check_signups_for_dup');
    
    function check_signups_for_dup($arrResult)
    {
        //If errors already exist just send it back
        if (!empty($arrResult['errors']->errors['user_name']) || !empty($arrResult['errors']->errors['user_email'])) {
            return $arrResult;
        }
    
        global $wpdb;
    
        $strUsernameQry = "SELECT COUNT(*) FROM {$wpdb->prefix}signups WHERE active='0' AND user_login = %s";
        $strEmailQry = "SELECT COUNT(*) FROM {$wpdb->prefix}signups WHERE active='0' AND user_email = %s";
    
        $intUsernames = $wpdb->get_var($wpdb->prepare($strUsernameQry, $arrResult['user_name']));
        $intEmails = $wpdb->get_var($wpdb->prepare($strEmailQry, $arrResult['user_email']));
    
        if (!empty($intUsernames)) {
            $arrResult['errors']->add('user_name', 'Sorry, a signup with that username already exists');
        }
    
        if (!empty($intEmails)) {
            $arrResult['errors']->add('user_email', 'Sorry, a signup with that email already exists');
        }
    
        return $arrResult;
    }

    @shanebp

    Moderator

    Thanks for opening the ticket.
    https://buddypress.trac.wordpress.org/ticket/6895
    In the ticket, please add a reference to this thread and also paste your useful filter.

    @baldgoat

    Participant

    Done and done.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘bp_core_validate_email_address doesn’t check signups table’ is closed to new replies.
Skip to toolbar