BuddyDev

Search

Replies

  • Participant
    Level: Guru
    Posts: 885

    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

  • Participant
    Level: Guru
    Posts: 885

    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

  • Participant
    Level: Guru
    Posts: 885

    Hello Brajesh,

    I just updated the plugin now and it works perfectly. Just to let you know, I am using this plugin with the buddyboss wall plugin but I only enabled the stream on the site wide activity page and not the profile page, I don’t think there is any form of conflict. If possible I can send you a copy of the buddyboss wall plugin to check it out for compatibility issues.

    Thank you so much
    Tosin

  • Participant
    Level: Guru
    Posts: 885

    Hello Brajesh,

    Thank you so much for explaining, I was also wondering if it will be possible to also change the all members label for only logged in users.

    1. Logged in users will see the label (My wall) while logged out users will see (all members) label.

    2. When a user is logged out does the site wide activity page revert back to the default all members activities.

    Thanks
    Tosin

  • Participant
    Level: Guru
    Posts: 885

    Hello Brajesh,

    Thank you so very much i’m very grateful. You even took the plugin a step further.

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: BuddyPress Clear Notifications support for Klein theme #14824
    This reply has been marked as private.
  • Participant
    Level: Guru
    Posts: 885

    The code worked successfully thank you very much Brajesh, God bless.

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14489

    Thank you Brajesh I will be looking forward to the update. But please note that the default activity should be set to (my wall or stream tab) for the logged in users and not (all members tab) while the default activity for logged out users should be set to (all members tab)

    Thank you very much, have a great day.

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14446

    Hello Brajesh,

    I think I have a better solution, how can i enable the (Facebook Like User Activity Stream for BuddyPress plugin) to work on the site wide activities page for logged in users since this will also pick activities of users i’m following.

    I have version 1.1.7 installed

    Thank you for your patience

  • Participant
    Level: Guru
    Posts: 885
    Tosin on in reply to: Display sitewide activity for followers only #14445

    How can I make this code show all members for logged out users

     /**
     * Set default activity directory tab for BuddyPress
     */
    function buddydev_set_default_activity_directory_tab() {
        // If user is not logged in or
        // If the scope is already set, do not do anything ok.
        if ( ! is_user_logged_in() || isset( $_COOKIE['bp-activity-scope'] ) ) {
            return ;
        }
        // additional check for activity dir
        if ( ! bp_is_activity_directory() ) {
            return ;
        }
        $tab = 'following'; // 'all', 'friends', 'groups', 'mentions'
        // Set scope to our needed tab,
        // In this case, I am setting to the 'friends' tab
        setcookie( 'bp-activity-scope', $tab,null, '/' );
        $_COOKIE['bp-activity-scope'] = $tab;
    }
    add_action( 'bp_template_redirect', 'buddydev_set_default_activity_directory_tab' ); 

    I will now be able to apply the two codes in my bp-custom.php file, one code for logged in users(this will show activities of people i’m following) while the other code is for logged out users (this will show activities of all members).

    Thank you