The MU forums have moved to

Redirecting based upon given link after login (3 posts)

  1. JsonB123
    Posted 11 years ago #

    I'm using the plugin "More Privacy Options" version 2.9.3 to make certain blogs private, this is working wonderfully. I want to know if it's possible to, based upon a link, redirect a user, after they log in, to a specified page on a private site based on that specific link...not just their home page.

    I'm using a login redirect plugin to route users to their sites main page...but sometimes I want to give them a link that will reroute them to a specific page on their site. This works if they are already logged in but not if they are logged out. If they are logged out they are presented with the login screen but upon logging in they just go to the main page...not the one specified by the link...make sense?

    Is there a plugin or some PHP I can use to make this happen?

  2. mr.tirtakusuma
    Posted 10 years ago #

  3. ancawonka
    Posted 10 years ago #

    Here's the PHP code I added to my theme to provide just that feature:

    if (is_user_logged_in()){
       global $current_user;
       if ( ! isset($current_user) ) $current_user = wp_get_current_user();
          <a href="link to your content">Link to Protected Content</a>
    	} else {
    	<a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login to edit</a>

    The relevant thing to note is the function wp_login_url (

    It displays a login link and sets a redirect, such that, upon login, they are taken to the right page.

About this Topic

  • Started 11 years ago by JsonB123
  • Latest reply from ancawonka