Skip to:
Content
Pages
Categories
Search
Top
Bottom

Login Redirect

Viewing 5 replies - 1 through 5 (of 5 total)

  • sharmavishal
    Participant

    @sharmavishal

    you need to check with lifterlms on this…as its a custom theme


    coffeywebdev
    Participant

    @coffeywebdev

    You could try using the WordPress API, there is a function called login_redirect()

    /**
     * Redirect user after successful login.
     *
     * @param string $redirect_to URL to redirect to.
     * @param string $request URL the user is coming from.
     * @param object $user Logged user's data.
     * @return string
     */
    function my_login_redirect( $redirect_to, $request, $user ) {
    	//is there a user to check?
    	if ( isset( $user->roles ) && is_array( $user->roles ) ) {
    		//check for admins
    		if ( in_array( 'administrator', $user->roles ) ) {
    			// redirect them to the default place
    			return $redirect_to;
    		} else {
    			return home_url();
    		}
    	} else {
    		return $redirect_to;
    	}
    }
    
    add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

    You need to add something like the code above your child theme functions.php file, or you can create a plugin and add this code to it.

    https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect


    Earl_D
    Participant

    @earl_d

    Don’t know if it will work with your theme but you may want to look at the code snippets here

    Login redirects not working


    buddycore
    Participant

    @buddycore

    You can achieve this with a custom login link which is accessed by a user on your site front…

    <?php echo wp_login_url(home_url('/')); ?>

    When clicked the login form will process a redirect after logging in.

    That wont work if you access the wp-login.php directly.

    @coffeewebdev looks like he’s given you a more all-round solution.


    gsawa222
    Participant

    @gsawa222

    I disabled ALL plugins besides for the Buddypress plugin. I am additionally the use of the Twenty Fifteen subject matter as you can see here. The errors is still happening once I go to exchange the picture

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar