WordPress.org

Ready to get started?Download WordPress

Forums

jonradio Private Site
[resolved] Free Mod/Hack - Redirect to a page OTHER than the login page (1 post)

  1. foxymcfox
    Member
    Posted 1 year ago #

    I just made a small mod to this plugin, so I figured I'd share it in case it's useful for anyone else.

    My situation was that I have a custom sign-in page that I wanted to redirect users to, instead of sending them to the WP page. This was the most streamlined private site plugin I could find, so it was a cinch to modify. All I did was modify the jr_ps_force_login function slightly to add an additional check that determines if the user is on the page I want them to be on (In my case, the page name is "sign-in") and if they are not, passes them to a wp_redirect (instead of the auth_redirect) that then redirects them to the chosen page. I decided to use "site_url" over "network_home_url" so that this would work on a multisite install to redirect users to a page specific to THAT subdomain/directory rather than of the main site.

    Anyway, my writeup is now much longer than the mod I made so here is the modified section for your use and enjoyment:

    function jr_ps_force_login() {
    	global $jr_ps_is_login;
    	if ( !is_user_logged_in() && !isset( $jr_ps_is_login ) && !is_admin() && !is_page('sign-in')) {
    		wp_redirect(site_url( '/sign-in'));
    		exit;
    	}
    }

    ...just copy and paste this over the original function, replace "sign-in" with whatever page you want, and you're good to go.

    I may continue forking this a little bit more to add an admin panel where you can select the page you'd like the users redirected to. If and when I do, I'll share it freely.

    Enjoy! And thanks for the great starting point jonradio!

    -Nick

    http://wordpress.org/extend/plugins/jonradio-private-site/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic