Redirect to specific messages when not logged in
-
I have a WordPress site with BuddyPress and bbPress forums.
Much of the site is available to logged in users only.Email notifications of new activity include a link to follow. When followed to something only available when logged in, the user is invited to login and is then redirected to the original target page. This mostly works but not in certain cases involving BuddyPress.
https://mysite.org.uk/members/myusername/messages
This works correctly. After login, the user is taken to their messages page.
https://mysite.org.uk/members/myusername/messages/view/572/
This should redirect to a specific message which does exist. This works OK if already logged in.
If not logged in, it redirects to my 404 apology page (as set in the Redirect plugin) without the login form being shown.For information, I have a bespoke login widget based on the BuddyPress login widget. It tailors the login form to my requirements. But I think these errors are arising in handling an inaccessible page and before the login form gets presented.
Any pointers or information about how WP processes these URLs will be appreciated.
I confirm this is the case using the Twenty Tewnty-Five theme.
WP 6.7
BuddyPress 14.3.3
bbPress 2.6.11
PHP 8.3
-
Hi @antipole,
It is difficult to say but, normally, there would be a redirect to the
wp-login.php
, given your example:https://mysite.org.uk/members/myusername/messages/view/572/
The above would, normally, redirect to:
https://mysite.org.uk/wp-login.php?redirect_to=https%3A%2F%2Fmysite.org.uk%2Fmembers%2Fmyusername%2Fmessages%2Fview%2F572%2F&bp-auth=1&action=bpnoaccess
The redirect is due to a page that requires authentication and if not authenticated, there is an attempt to redirect to
wp-login.php
. Since this does not happen, it may be that your Redirect plugin is bypassingwp-login.php
and redirecting to your 404 page, instead. I’m not sure if this is configuration issue with the Redirect plugin or just the way it works or if there is another cause.In a nutshell the flow is:
bp_core_no_access()
bp_core_redirect()
wp_safe_redirect()
I have now traced this to the All in One WP Security plugin. If this is disabled, the URL does take me to the login and thence to the message.
I will report it to AIOWPS.
OK, sounds good, I’m glad you were able to figure out the cause. May I consider this topic resolved?
- You must be logged in to reply to this topic.