redirect to wp-login.php!
-
Hi
I enabled ultimate member plugin and turned off “Anyone can register” in wordpress setting but when a user needs to enter a page that needs login or register it redirects to
https://test.com/wp-login.php?redirect_to=https%3A%2F%2Ftest.com%2Fdashboard%2F
not to ultimate member login or register page!
Can you help me to resolve this?
Thanks
The page I need help with: [log in to see the link]
-
at this moment I installed ‘Theme My Login’ plugin to solve the problem temporarily (I mean this plugin redirect wp-loign to login) Until you help me for the main problem.
I suggest that you keep the redirection with the Theme My Login. The other way is to add a code for the redirection.
Regards,
Can you please tell me what code I can use instead of this plugin?
I got some problem with Theme My Login in translation! (even with loco plugin I can’t translate them!)
Please try adding the following code snippets to your theme/child-theme’s functions.php file or use the Code Snippets plugin to run the code:
add_action('init','um_102521_redirect_to_um_login'); function um_102521_redirect_to_um_login(){ global $pagenow; if( ! function_exists("um_get_core_page" ) ) return; if( 'wp-login.php' == $pagenow ) { wp_redirect( um_get_core_page("login") ); exit(); } }Regards,
I have used this code before.
this code redirects wp-login.php page to /login/ that clears the previous path.
I mean when I want to go to ‘test.com/dashboard’ it goes to ‘test.com/login’ then Can not take me back to the previous address!
while ‘Theme My Login’ takes me back to the previous address like this:
I go to this link:
1. https://test.com/dashboard/
and then it happens
2. https://test.com/login/?redirect_to=https%3A%2F%2Ftest.com%2Fdashboard%2F
How can I get this without ‘Theme My Login’?
—
This was just an example. I want any page that requires user login, go through Ultimate Member Login Page not wp-login! and then go back to previous page.
Thanks
Please try this one:
add_action('init','um_102521_redirect_to_um_login'); function um_102521_redirect_to_um_login(){ global $pagenow; if( ! function_exists("um_get_core_page" ) ) return; if( 'wp-login.php' == $pagenow ) { $redirect_to = ''; if( isset( $_REQUEST['redirect_to'] ) ){ $redirect_to = "?redirect_to=".$_REQUEST['redirect_to']; } wp_redirect( um_get_core_page("login") . $redirect_to ); exit(); } }Regards,
-
This reply was modified 4 years, 6 months ago by
Champ Camba.
Result:
click on Dashboard:
https:/test.com/dashboard/
Next:
https:/test.com/login/https:/test.com/dashboard/
and I got a 404 page (Not Found)
So this code doesn’t work
-
This reply was modified 4 years, 6 months ago by
mohamaddapper.
I’ve updated the code. Maybe you received a notification with the old code. Please see the updated code above in the topic.
Regards,
Yes It worked 🙂
Thanks a lotCan you please tell me a solution for this too?
in my site when I click on logout button
*https://test.com/wp-login.php?action=logout&_wpnonce=023fce2d77*
it redirects to *https://test.com/login* Showing some details about my account (photo, name, account, logout)
then I have to click on logout button (https://test.com/logout/?redirect_to=https://test.com/login/) again to logout from my account.
How can I remove this page (https://test.com/login) from the path?
-
This reply was modified 4 years, 6 months ago by
mohamaddapper.
-
This reply was modified 4 years, 6 months ago by
mohamaddapper.
Please try this one:
add_action('init','um_102521_redirect_to_um_login'); function um_102521_redirect_to_um_login(){ global $pagenow; if( ! function_exists("um_get_core_page" ) ) return; if( isset( $_REQUEST['action'] ) && "logout" == $_REQUEST['action'] ) return; if( 'wp-login.php' == $pagenow ) { $redirect_to = ''; if( isset( $_REQUEST['redirect_to'] ) ){ $redirect_to = "?redirect_to=".$_REQUEST['redirect_to']; } wp_redirect( um_get_core_page("login") . $redirect_to ); exit(); } }Regards,
Thanks a lot. It Works Well
Thank you very much again
Thanks for letting us know.
Regards,
-
This reply was modified 4 years, 6 months ago by
The topic ‘redirect to wp-login.php!’ is closed to new replies.