-
AuthorPosts
-
December 20, 2015 at 3:18 pm #555594
Hello,
single post login (you must be logged in to post a comment) redirects to /wp-login.php. I would like it to redirect to /myaccount page, where registration form is. ThanksDecember 20, 2015 at 8:57 pm #555652Hi demarko19!
Please try a plugin like
https://wordpress.org/plugins/theme-my-login/and let us know if that is what you was in need
Cheers!
BasilisDecember 21, 2015 at 6:02 pm #556091Thanks for reply, Basilis. Plugin creates second registration, form. Plus it redirects hidden wp-admin login to simple login. And since copy/paste isn’t allowed on my website, it would be a hell to write 20+ letter long pwd every time :)
A bit of google and editing gave me a few codes to child functions.php.
This one resolved redirection to myaccount page:add_filter( 'comment_form_defaults', 'my_custom_phrase' ); function my_custom_phrase( $array ){ $array['must_log_in'] = sprintf( __( '<p class="must-log-in">Please <a href="%s">Log In</a> to post a comment.</p>' ), get_permalink( wc_get_page_id( 'myaccount' ) ) ); return $array; }
Since woocommerce by default, after login redirects to my account and not previous visited page, I thought this might help:
// Custom redirect for users after logging in add_filter('woocommerce_login_redirect', 'wcs_login_redirect'); function wcs_login_redirect( $redirect ) { //Redirect to the previous visited page or, if not available, to the home $redirect = wp_get_referer() ? wp_get_referer() : home_url(); return $redirect; }
But it redirects to home page. And if I delete ? wp_get_referer() : home_url(). It redirects to empty page.
Your team is great with codes, maybe you can help me with this :)December 21, 2015 at 9:17 pm #556181Hi!
Try the following code, to redirect to previous page after login:
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(); } }
Best regards,
BasilisDecember 21, 2015 at 10:23 pm #556213Hi. It redirects to myaccount page same as woo default.
December 27, 2015 at 1:44 pm #557601Hey!
I’d suggest posting your question in the WP Forums as it’s more related to a WordPress-specific functionality:
https://wordpress.org/support/Regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.