BuddyDev

Search

[Resolved] Branded login issues

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47496

    Hello,

    I recently noticed two issues with the Branded login plugin.

    1.) When I visit the login page and leave either the email field or password field empty and I click on the login button i’m being redirected to the site wide activity page while logged out instead of remaining on the same page and throwing a login error message.

    2.) In the password reset page if email field is empty and I click on the get ne password button this error message is displayed (Your Username is empty. Please enter your Username.) I would rather want the error message to be (Your Email Address is empty. Please enter your Email Address.)

    This are the code I have in my bp-custom.php relating to login redirect and branded login

     // login all users to news-feed page (for logged out users)
    function site_login_redirect_to_news_feed() {
    	if ( ! is_user_logged_in() ) {
    		bp_core_redirect( bp_get_activity_directory_permalink() );
    		exit( 0 );
    	}
    }
    add_filter( 'bp_login_redirect', 'site_login_redirect_to_news_feed', 11, 3 ); 
     
    
    // branded-login filter for frontend password creation
    add_filter( 'bl_allow_creating_password', '__return_true' );
    
    /**
     * Email login support for bp-branded-login plugin
     */
    add_filter( 'wp_authenticate_user', function( $user ) {
    	if ( isset( $_POST['log'] ) && ! is_email( trim( $_POST['log'] ) ) ) {
    		return new WP_Error( 'invalid_email', __( 'Please provide a valid email' ) );
    	}
    	return $user;
    }, 10 );
    
    /**
     * Filter bp-branded-login plugin logout url.
     *
     * @return string
     */
    function bl_custom_filter_logout_url( $url ) {
    
    	if ( is_admin() && ! defined( 'DOINGAJAX' ) ) {
    		return $url;
    	}
    
    	$logout_url = bl_get_logout_link();
    
    	if ( empty( $logout_url ) ) {
    		return $url;
    	}
    
    	$redirect = 'https://www.nigerpress.com/login/';// change with actual.
    	// $redirect = wp_validate_redirect( $redirect );
    
    	if ( $redirect ) {
    		$query['redirect_to'] = $redirect;
    	}
    
    	$logout_url = add_query_arg( $query, $logout_url );
    
    	return $logout_url;
    }
    add_filter( 'logout_url', 'bl_custom_filter_logout_url', 100 );
    
     
  • Keymaster
    (BuddyDev Team)
    Posts: 24190
    Brajesh Singh on #47509

    Hi Tosin,
    I am sorry for the inconvenience.
    i am not seeing any issue with the code. @ravisharma or I will be validating your code today and getting back to you.

    In the meantime, Is there any chance that you are using a plugin that hooks to login process or is there some kind of cache active?

    Thank you
    Brajesh

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2932
    Ravi on #47516

    Hello Tosin,

    Replace the code section with the following one:

    
    // login all users to the news-feed page (for logged-out users)
    function site_login_redirect_to_news_feed( $redirect_to, $redirect_to_raw, $user ) {
    	if ( ! is_wp_error( $user ) && ! is_user_logged_in() ) {
    		bp_core_redirect( bp_get_activity_directory_permalink() );
    		exit( 0 );
    	}
    }
    add_filter( 'bp_login_redirect', 'site_login_redirect_to_news_feed', 11, 3 );
    
    

    For modifying the message on password reset you can use any translation plugin and modify it.

    Please check it.

    Regards
    Ravi

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47517

    Thanks Ravi,

    The code worked perfectly

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2932
    Ravi on #47523

    Hello Tosin,

    Thank you for the acknowledgment. I am glad that I could help.

    Regards
    Ravi

The topic ‘ [Resolved] Branded login issues’ is closed to new replies.

This topic is: resolved