WordPress.org

Ready to get started?Download WordPress

Forums

Login With Ajax
User based redirect to profile just on Frontpage (2 posts)

  1. BBIndikator
    Member
    Posted 4 months ago #

    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/

  2. BBIndikator
    Member
    Posted 4 months ago #

    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;
    	}

Reply

You must log in to post.

About this Plugin

About this Topic

Tags