Skip to:
Content

Opened 11 months ago

Closed 6 months ago

#5042 closed enhancement (fixed)

Disable certain pages for logged-in users

Reported by: henrywright Owned by: 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 10 months ago.

Download all attachments as: .zip

Change History (7)

comment:1 henrywright10 months 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 10 months ago by henrywright (previous) (diff)

comment:2 boonebgorges10 months 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?

comment:3 henrywright10 months 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');

comment:4 henrywright10 months ago

  • Keywords reporter-feedback removed

comment:5 boonebgorges10 months 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.

boonebgorges10 months ago

comment:6 boonebgorges6 months 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.