WordPress.org

Support

Support » Plugins and Hacks » User based redirect to profile just on Frontpage

User based redirect to profile just on Frontpage

  • Hello,

    hope anybody has a tip for me ?

    I need a redirect for subscribers and customers to their BuddyPress Profile just if they login on Frontpage. Inside the lwa-settings for their redirect on login, I have no entries, because in our Header is a hidden Login-form. On this way they can login everywhere and stays on the page, post e.g.

    I tried to fix it inside the login-with-ajax.php

    On line 313 is this function defined:

    public static function loginRedirect( $redirect, $redirect_notsurewhatthisis, $user ){
    		$data = self::$data;
    		if(is_user_logged_in()){
    			$lwa_redirect = self::getLoginRedirect($user);
    			if( $lwa_redirect != '' ){
    				wp_redirect($lwa_redirect);
    				exit();
    			}
    		}
    		return $redirect;
    	}

    I changed it to this:

    public static function loginRedirect( $redirect, $redirect_notsurewhatthisis, $current_user, $user ){
    		$data = self::$data;
    
    		global $current_user;
    		if(!current_user_can('edit_posts') && is_page(42600)){
    			wp_redirect( get_bloginfo('url') . '/members/'. $current_user->user_login . '/profile/');
    			exit();
    		}
    
    		else if(is_user_logged_in()){
    			$lwa_redirect = self::getLoginRedirect($user);
    			if( $lwa_redirect != '' ){
    				wp_redirect($lwa_redirect);
    				exit();
    			}
    		}
    
    		return $redirect;
    	}

    But it don´t work. It stays every time at the Frontpage.

    I ried it also with:

    if(!current_user_can('edit_posts') && is_front_page() && !is_paged()){

    No luck. I´m at the beginning with php development and my skills this time not the best. What should I do ?

    Best regards

    https://wordpress.org/plugins/login-with-ajax/

Viewing 1 replies (of 1 total)
  • This don´t work, too..

    public static function loginRedirect( $redirect, $redirect_notsurewhatthisis, $current_user, $user ){
    		$data = self::$data;
    
    		global $current_user;
    		if ( ! current_user_can( 'edit_posts' ) && ( is_front_page() || is_home() ) ) {
    			wp_redirect( get_bloginfo('url') . '/members/'. $current_user->user_login . '/profile/');
    			exit();
    		}
    
    		else if(is_user_logged_in()){
    			$lwa_redirect = self::getLoginRedirect($user);
    			if( $lwa_redirect != '' ){
    				wp_redirect($lwa_redirect);
    				exit();
    			}
    		}
    		return $redirect;
    	}
Viewing 1 replies (of 1 total)
  • The topic ‘User based redirect to profile just on Frontpage’ is closed to new replies.