FIXED PARTIALLY. I was using BP Redirect To Profile so I disabled it, the contents are still private and it doesn’t keep redirecting.
But the problem I am having is that after login it will just refresh the login page without directing to anywhere. Some people won’t know that they have been logged in already. That is why I used to Redirect Plugin initially so that it can direct to somewhere.
So asking the masters, how can the login direct to where they left off? For instance, sent a logged out user a group link, and his tries to visit the groups and login page appears, how can he continue straight to the group after login?
It looks, at a glance, like the LH Private BuddyPress plugin ought to be doing what you’re asking for. https://plugins.trac.wordpress.org/browser/lh-private-buddypress/trunk/lh-private-buddypress.php#L101
If it’s not working, it’s either because of an error in the plugin logic, or because something on your server or WP setup is interfering with the redirect_to
parameter.
Can you share the format of the URL at various points of the process? For example, when visiting example.com/groups/my-private-group as a logged-out user, you should be redirected to:
example.com/wp-login.php?redirect_to=/groups/my-private-group
If, after login, you’re being redirected back to wp-login.php, what is the format of the URL then?
What is the URL format of your BP/WP installation? Are you installed at the top level of a domain example.com
or in a subdirectory example.com/buddypress/
?
LH Private BP works, I don’t know if you understood the problem I am having. This is my problem, after login the page just refreshes, but the user has already been logged in, then he can browse the site as a logged in member. But might be under the impression that he has not logged in because it didn’t take him to where he was about to go before he was requested to login.
Logged out user Before login, going to a group named ‘the blog coach’ he clicks on the link sent by a friend example.com/groups/the-blog-coach
he gets redirected to
https://www.example.com/login/?redirect_to=%2Fgroups%2Fthe-blog-coach%2F
Link after logging in still directed to
https://www.example.com/login/?redirect_to=%2Fgroups%2Fthe-blog-coach%2F
the page just refreshes no direction. i copied the links uniquely before and after login.
Before you respond to this, please try to make me understand how far you have understood me and my problem so far? Thanks so far
What plugin are you using to put the login at example.com/login instead of example.com/wp-login.php? It’s likely that this is involved in causing the redirect trouble.
Rename wp-login. Well, its a community site where everybody is logging in, generation community sites comes with Login, not wp-admin. And worse amateurs will know that you are running WP and think there is nothing different from your big website and their blog.
Thanks. I’ve just installed the combination of rename-wp-login and lh-private-buddypress, and I’m unable to reproduce the problem – after logging in, I’m being redirected to the originally-requested page. It may still be worth a test on your end; if temporarily disabling rename-wp-login fixes the problem, it would at least narrow down what’s going on.
If it were my site, the next thing I’d do is to debug the redirection chain, but I’m unsure how familiar/comfortable you are with debugging PHP functions. Try adding the following settings to your wp-config.php:
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_DISPLAY', false );
define( 'WP_DEBUG_LOG', true );
After a few pageloads, WP should have created a file at wp-content/debug.log. Once you’ve confirmed this, drop the following into a bp-custom.php file, and then run through the login redirect process. It’ll dump some info into your debug.log file, which we can use for further debugging.
add_filter( 'wp_redirect', function( $redirect ) {
error_log( print_r( debug_backtrace(), true ) );
return $redirect;
} );
You know at times all these programming stuff just pile up in your head and overflow sometimes.
SO I disabled the Rename WP Login and then (wp-admin) then everything worked fine. So what do you propose i do? Since i don’t want to use default wp-admin login.
you could make a custom login page in your child-theme.
You could try using a different plugin for switching the login page. https://wordpress.org/plugins/search/login+page/ The one I’ve seen in use before is Theme My Login. Maybe it will work better with your setup.
@peter-hamilton @boonebgorges suggestions like this make my head hurt. Put yourself in my shoes, wouldn’t you guys agree more?
My suggestion was to try another plugin. That’s a relatively low-risk proposal 🙂
For the record, I understand the frustration – piecing together many different plugins and tools, written by many different people, can sometimes have unpredictable results.
lol, did not mean to break your head.
Do you have a child-theme?
If you add the following code to your functions.php your members should return to the page they logged-in from.
if ( (isset($_GET['action']) && $_GET['action'] != 'logout') || (isset($_POST['login_location']) && !empty($_POST['login_location'])) ) {
add_filter('login_redirect', 'my_login_redirect', 10, 3);
function my_login_redirect() {
$location = $_SERVER['HTTP_REFERER'];
wp_safe_redirect($location);
exit();
}
}
@peter-hamilton didn’t work.
I also copied wp-login and renamed everything wp-login.php
with login.php
but it behaves as if I was using the Rename wp-login plugin. It logs in but doesn’t redirect. Well, I think I will just leave everything as wp-login for now, maybe something needs to be updated somewhere before custom login will fully replace the function of wp-login. Thanks for your support so far.