WordPress.org

Ready to get started?Download WordPress

Forums

More Privacy Options
Custom login/register pages? (5 posts)

  1. Samantha Miller.
    Member
    Posted 1 year ago #

    Hi,

    I have a multisite install with a public website as the main site, and a members-only section that uses BuddyPress as a subsite on a subdomian.

    I had the site set up to be private unless a user was logged in, with only custom login and register pages available to the public. I have since found that users that are registered to the main site could view the private site, despite that user not being assigned to the private site, hence me using this plugin.

    My issue now is that I cannot make the login and register pages public again. I've used this code to change the location of the register page:

    add_filter( 'wp_signup_location', 'register_page' );
    	function register_page( $location ) {
    		return '/register/';
    	}

    The link on the default wp-login page that says "Register first as a network user" is linking to the right page, but it just gets redirected back to the default login.

    The only pages I do not want to be private are /login/ and /register/.

    Any help is appreciated, thanks!

    http://wordpress.org/extend/plugins/more-privacy-options/

  2. Samantha Miller.
    Member
    Posted 1 year ago #

    I ended up reverting back to using Private BuddyPress instead of this plugin, then doing a check to see if the current user is a member of the current site and logging them out if they're not.

    function log_out_non_currentsite_users() {
    	    global $current_user;
    		get_currentuserinfo();
    		if (is_user_logged_in() && !is_user_member_of_blog($current_user->ID)) {
    			wp_logout();
    		}
    	}
    	add_action('init', 'log_out_non_currentsite_users');

    This works for my situation as the user on the main site is a generic user that many people will access, while the private area has a different user for each person.

    This doesn't seem like as much of a solid solution, but the does the trick. Any comments welcome.

  3. David Sader
    Member
    Plugin Author

    Posted 1 year ago #

    I do not run a BuddyPress install so I am not familiar with all its nuances. Sounds like you are figuring it out, though.

    Does adding the following to the top of my plugin just before the Hooks help?

    if( strpos($_SERVER['REQUEST_URI'], '/register/')) return;

  4. David Sader
    Member
    Plugin Author

    Posted 1 year ago #

    Further, without editing my plugin but adding to your own a function to remove the actions added by my plugin if the page url contains /register/

    <?php
    add_filter( 'wp_signup_location', 'register_page' );
    	function register_page( $location ) {
    		return '/register/';
    	}
    
    add_action('send_headers','ds_more_privacy_options_register_page',10);
    	function ds_more_privacy_options_register_page() {
    		global $ds_more_privacy_options;
    
    		if( strpos($_SERVER['REQUEST_URI'], '/register/')) {
    			remove_action('template_redirect', array($ds_more_privacy_options, 'ds_users_authenticator'),10);
    			remove_action('template_redirect', array($ds_more_privacy_options, 'ds_members_authenticator'),10);
    			remove_action('template_redirect', array($ds_more_privacy_options, 'ds_admins_authenticator'),10);
    		}
    	}
    ?>
  5. Samantha Miller.
    Member
    Posted 1 year ago #

    Thanks for your reply David. I will test over the weekend and get back to you.

    Samantha

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic