BuddyDev

Search

[Resolved] BuddyPress Auto Activate Auto Login email login problem

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #16082

    Hello Brajesh,

    I recently purchased the BuddyPress Auto Activate Auto Login plugin, but I realised the the plugin does not work with Email address being used as login input instead of username. My site uses email address instead of username to login for security reasons.

    When I register a new user, the account becomes active automatically but the automatic login fails because i’m using email address instead of username.

    Tosin

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #16083

    Hi Tosin,
    Thank you for reporting. I am pushing an update today. It has been long due for the Auto Activate as well as the Ajax Registration plugin since WordPress not supports email login out of the box.

    Please allow me to have an update by day end today.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #16104

    Hi Tosin,
    I checked the plugin now. It is working for me even if I use the email as username. Are you using any plugin that prevents login by username? That may be the reason.

    Please let me know and I will assist further.

    Thank you
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #16105

    Hello Brajesh,

    I’m using a plugin to prevent usernames and accept only on email address on login, is there a way to work around this because I don’t want my users to be able to login using their username but only their email address.

    1. For security reasons logins with email address is better as I want to use usernames for communication purpose only in the community.

    2. Users cannot easily identity another user’s email address unlike usernames that are publicly visible during communication in buddypress.

    Thanks

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #16108

    Hi Tosin,
    No problem. Please let me know if you are accomplishing it via some plugin or code and I can add compatibility.

    I need to know about the above to devise a strategy for authenticating via email instead of username.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #16110

    Hello Brajesh,

    I am using two methods to achieve (1) through the ithemes security plugin (2) through custom code in my functions.php file

    1. Using the ithemes security plugin by navigating to settings the wordpress tweaks

    2. Below is the custom code applied to my functions.php file

     /* ------------------------------------------------------------------------- *
     * Remove WordPress default authentication function
    /* ------------------------------------------------------------------------- */
    remove_filter('authenticate', 'wp_authenticate_username_password', 20);
    
    /* ------------------------------------------------------------------------- *
     * Add custom authentication function
    /* ------------------------------------------------------------------------- */
    add_filter('authenticate', function($user, $email, $password){
    
        //Check for empty fields
        if(empty($email) || empty ($password)){        
            //create new error object and add errors to it.
            $error = new WP_Error();
    
            if(empty($email)){ //No email
                $error->add('empty_username', __('<strong>ERROR</strong>: Email field is empty.'));
            }
            else if(!filter_var($email, FILTER_VALIDATE_EMAIL)){ //Invalid Email
                $error->add('invalid_username', __('<strong>ERROR</strong>: Email is invalid.'));
            }
    
            if(empty($password)){ //No password
                $error->add('empty_password', __('<strong>ERROR</strong>: Password field is empty.'));
            }
    
            return $error;
        }
    
        //Check if user exists in WordPress database
        $user = get_user_by('email', $email);
    
        //bad email
        if(!$user){
            $error = new WP_Error();
            $error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.'));
            return $error;
        }
        else{ //check password
            if(!wp_check_password($password, $user->user_pass, $user->ID)){ //bad password
                $error = new WP_Error();
                $error->add('invalid', __('<strong>ERROR</strong>: Either the email or password you entered is invalid.'));
                return $error;
            }else{
                return $user; //passed
            }
        }
    }, 20, 3); 

    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #16113

    Thank you. I will have an update today for you.

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #16150

    Hello Brajesh,

    I have not received any feed back yet with regards to the update.

    Thank you

  • Keymaster
    (BuddyDev Team)
    Posts: 24623
    Brajesh Singh on #16154

    Hi Tosin,
    Please upgrade to 1.4.7
    https://buddydev.com/plugins/bp-auto-activate-auto-login/

    After that, please put this in in your bp-custom.php

    
    add_filter( 'bp_autoactivate_use_email_login', '__return_true' );
    
    

    That will do it.

    Regards
    Brajesh

  • Participant
    Level: Guru
    Posts: 900
    Tosin on #16188

    Hello Brajesh,

    The updated plugin and the filter worked successfully, thank you so very much.

    Tosin

The topic ‘ [Resolved] BuddyPress Auto Activate Auto Login email login problem’ is closed to new replies.

This topic is: resolved