Skip to:
Content

BuddyPress.org

Opened 11 years ago

Closed 10 years ago

#5042 closed enhancement (fixed)

Disable certain pages for logged-in users

Reported by: henrywright's profile henrywright Owned by: boonebgorges's profile boonebgorges
Milestone: 1.9 Priority: normal
Severity: normal Version: 1.7
Component: Core Keywords: has-patch
Cc:

Description

I can't think of a reason why the lost password, login, register, activate, reset password pages etc should be available to logged-in users. If a logged in user attempts to access one of these pages then perhaps something should happen such as a redirect to the member's profile page?

Attachments (1)

5042.patch (792 bytes) - added by boonebgorges 11 years ago.

Download all attachments as: .zip

Change History (7)

#1 @henrywright
11 years ago

This is how I am doing it. The conditional just checks for logged in users visiting the homepage but this could be changed or added to if necessary.

function bp_redirect_loggedin_to_profile() {
	global $bp;
	
	if ( is_user_logged_in() && bp_is_front_page() ) {
		wp_redirect( $bp->loggedin_user->domain );
                exit;
	}
}
add_action('wp','bp_redirect_loggedin_to_profile');

Last edited 11 years ago by henrywright (previous) (diff)

#2 @boonebgorges
11 years ago

  • Keywords reporter-feedback added

Lost password and Register are WP pages, so it's not really within the scope of BP to redirect away from them.

I'm pretty sure it's already the case that logged-in users are redirected away from the Register and Activate pages. Can you double check that that's the case?

#3 @henrywright
11 years ago

Hi Boone

Thanks for the feedback. Ah yes, of course, the lost password and reset password pages fall under the WP remit.

I can confirm that the the register page redirects to the homepage. However, the activate page does not redirect. A logged-in user is shown the activation form which asks for an activation key.

May I suggest:

//redirect logged in users to profile
function bp_redirect_activate_while_loggedin() {
	global $bp;
	
	if ( bp_is_activation_page() ) {
		wp_redirect( $bp->loggedin_user->domain );
		exit();
	}
}
add_action('wp','bp_redirect_activate_while_loggedin');

#4 @henrywright
11 years ago

  • Keywords reporter-feedback removed

#5 @boonebgorges
11 years ago

  • Keywords has-patch added
  • Milestone changed from Awaiting Review to 1.9

Thanks for looking into it more, henrywright. Here's what we currently do with the register page: http://buddypress.trac.wordpress.org/browser/tags/1.7.2/bp-members/bp-members-screens.php#L58 I'm thinking we should do something similar in the Activate screen function, just to be consistent (that'd be bp_core_screen_activation()). See 5042.patch.

@boonebgorges
11 years ago

#6 @boonebgorges
10 years ago

  • Owner set to boonebgorges
  • Resolution set to fixed
  • Status changed from new to closed

In 7438:

Don't allow logged-in users to access Activate page.

This behavior better parallels the behavior of the Register page.

Fixes #5042

Props henrywright

Note: See TracTickets for help on using tickets.