Skip to:
Content

bbPress.org

Opened 12 years ago

Closed 6 years ago

Last modified 5 years ago

#2188 closed enhancement (fixed)

Redirect to the home page after logout from a private forum/topic/reply

Reported by: alex-ye's profile alex-ye Owned by: johnjamesjacoby's profile johnjamesjacoby
Milestone: 2.6.1 Priority: normal
Severity: normal Version: 2.2.3
Component: Component - Users Keywords: commit
Cc: nashwan.doaqan@…, wordpress@…, jared@…, pippin@…

Description

Hi bbPress Lovers , When the user logout from a private forum/topic/reply the WordPress redirect the page to 404 error page .

I think we should redirect it to the home page since the private forum/topic/reply are only shown for users .

I prepare some codes about that , but I am not sure that this is a thing should be in the core !

Attachments (4)

common-functions.patch (4.8 KB) - added by alex-ye 11 years ago.
First Draft Patch
common-functions.2.patch (3.7 KB) - added by alex-ye 11 years ago.
0.2
2188.patch (2.0 KB) - added by johnjamesjacoby 6 years ago.
2188.02.patch (2.4 KB) - added by johnjamesjacoby 6 years ago.

Download all attachments as: .zip

Change History (23)

#1 @alex-ye
12 years ago

  • Cc nashwan.doaqan@… added
  • Component changed from General to Code Improvement

#2 @alex-ye
12 years ago

  • Component changed from Code Improvement to General
  • Type changed from defect to enhancement

#3 @johnjamesjacoby
12 years ago

  • Keywords 2nd-opinion removed
  • Milestone changed from Awaiting Review to 2.4

This needs to happen in a few places; basically, the redirects need to be a bit smarter. Too late for 2.3, so moving to 2.4.

#4 @MZAWeb
12 years ago

  • Cc wordpress@… added

#5 @jaredatch
11 years ago

  • Cc jared@… added

@alex-ye
11 years ago

First Draft Patch

#6 @alex-ye
11 years ago

  • Keywords has-patch needs-testing added; needs-patch removed

#7 @johnjamesjacoby
11 years ago

  • Milestone changed from 2.4 to 2.5

No time. Moving to 2.5.

#8 follow-up: @MZAWeb
11 years ago

Also the code now is doing:

// Rejig the $redirect_to
if ( !isset( $_SERVER['REDIRECT_URL'] ) || ( $redirect_to !== home_url( $_SERVER['REDIRECT_URL'] ) ) ) {
	$redirect_to = isset( $_SERVER['HTTP_REFERER'] ) ? $_SERVER['HTTP_REFERER'] : '';
}

$redirect_to = ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];

That if doesn't make any sense, as the last line is overwriting $redirect_to.

#9 in reply to: ↑ 8 @alex-ye
11 years ago

Replying to MZAWeb:

That if doesn't make any sense, as the last line is overwriting $redirect_to.

hhhh, I don't know what I was thinking about :D
I will update the patch soon..

#10 @alex-ye
11 years ago

Thanks MZAWeb :)

#11 @mordauk
11 years ago

  • Cc pippin@… added

Is there a function in bbPress for can_view( $post_id )? If so, that would make this dramatically simpler.

#12 @mordauk
11 years ago

Ah, here we go. How about just using bbp_user_can_view_forum()?

#13 @alex-ye
11 years ago

Sorry, but bbp_user_can_view_forum() doesn't work! for this reasons:

1- A BUG: if you see the function source code the check bbp_is_user_keymaster() doesn't use the $user_id variable.

I will open a another ticket about this now.

2- We need to check if the visitor can read the forum, so will need to pass the user_id => 0 and this will not work! because bbp_is_user_keymaster() will fallback to the current user ID :(

So..

I think we should introduce some functions if we want a really clean solution, maybe something like bbp_user_can_view_topic() and bbp_user_can_view_reply() and we should add a fourth argument in bbp_user_can_view_forum() let's called it guest=>(bool)

What's your thoughts?!

#14 @johnjamesjacoby
11 years ago

  • Component changed from General to Users
  • Keywords early added; has-patch removed
  • Milestone changed from 2.5 to 2.6

Patch looks okay at a cursory glance. Let's move this to 2.6 early, and get it in to test right away.

#15 @johnjamesjacoby
11 years ago

  • Milestone changed from 2.6 to 2.7

Bump to 2.7.

#16 @johnjamesjacoby
10 years ago

  • Milestone changed from 2.7 to 2.8

Bumping all 2.7 to 2.8 milestone.

#17 @johnjamesjacoby
6 years ago

  • Keywords commit added; needs-testing early removed
  • Milestone changed from 2.8 to 2.7

Working on a different approach for 2.7 now.

#18 @johnjamesjacoby
6 years ago

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

In 6863:

Login: Updates to bbp_logout_url():

  • Removes Apache-only REDIRECT_URL usage
  • Defaults to the Referer (for smart redirects)
  • Adds a filter to the redirect_to string
  • Validates the redirect_to after being filtered
  • Falls back to bbp_get_root_url() if invalid
  • Ensures that custom $redirect_to values are preserved

Fixes #2188.

#19 @johnjamesjacoby
5 years ago

  • Milestone changed from 2.7 to 2.6.1
Note: See TracTickets for help on using tickets.