Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WC Vendors › Logout Redirection
Tagged: wc vendors
- This topic has 13 replies, 3 voices, and was last updated 4 years, 5 months ago by Sushobhan.
- AuthorPosts
- April 29, 2020 at 5:31 pm #124652eguareoneParticipant
Hi Friends,
Please how do I redirect vendors to a custom URL when they log out from the frontend manager? I found some tips online but none worked… Any help will be appreciated. Thanks.
- April 29, 2020 at 7:13 pm #124689SushobhanKeymaster
Hi,
Thanks for getting in touch with us!
Please use the following snippet for your requirement-add_filter( 'wcfm_logout_url', function( $logout_url ) { if( wcfm_is_vendor() ) { return 'URL_YOU_WANT_TO_GET_REDIRECTED_TO'; // set your url here } return $logout_url; }); add_filter('woocommerce_get_endpoint_url', function($url, $endpoint, $value, $permalink) { if($permalink === 'URL_YOU_WANT_TO_GET_REDIRECTED_TO') { // repeat the same url return $permalink; } return $url; }, 10, 4);
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/
Let me know how this goes.
Thanks! - May 1, 2020 at 2:18 am #125215eguareoneParticipant
Hi thanks so much for your reply.
I’m not to clear on where to place the custom url on the code
Below is how i understand it. Custom url is https://abaaexpress.com.ng/seller-login
add_filter( 'wcfm_logout_url', function( $logout_url ) { if( wcfm_is_vendor() ) { return 'https://abaaexpress.com.ng/seller-login'; // set your url here } return $logout_url; }); add_filter('woocommerce_get_endpoint_url', function($url, $endpoint, $value, $permalink) { if($permalink === 'https://abaaexpress.com.ng/seller-login') { // repeat the same url return $permalink; } return $url; }, 10, 4);
Did I do it right?
Thanks again for your help.
- May 1, 2020 at 3:29 am #125225eguareoneParticipant
Never Mind, It worked but when it logs out it shows an incomplete site and changes the url to https://abaaexpress.com.ng/seller-login/?_wpnonce=fcd103599e instead of https://abaaexpress.com.ng/seller-login/
Is this normal?
- May 1, 2020 at 8:48 pm #125468SushobhanKeymaster
Sorry! The code wasn’t working. It was redirecting you to that page and not logging you out. Here is the updated code-
add_filter( 'wcfm_logout_url', function( $logout_url ) { if ( wcfm_is_vendor() ) { return 'https://abaaexpress.com.ng/seller-login/'; } return $logout_url; } ); add_filter( 'woocommerce_get_endpoint_url', function($url, $endpoint, $value, $permalink) { if ( $permalink === 'https://abaaexpress.com.ng/seller-login/' ) { return add_query_arg( 'wcfm_logout', 'yes', $permalink ); } return $url; }, 10, 4 ); function redirect_page() { global $wp; if ( ! empty( $_REQUEST['wcfm_logout'] ) && ! empty( $_REQUEST['_wpnonce'] ) && wp_verify_nonce( sanitize_key( $_REQUEST['_wpnonce'] ), 'customer-logout' ) ) { wp_safe_redirect( str_replace( '&', '&', wp_logout_url( esc_url_raw( 'https://abaaexpress.com.ng/seller-login/' ) ) ) ); exit; } } add_action( 'template_redirect', 'redirect_page' );
This should be a one line code but due to a known bug in WooCommerce, we have to take this ugly route!
Let me know how it goes.
Thank You! - May 2, 2020 at 8:43 pm #125763eguareoneParticipant
Thank you for this! I’m afraid that this new code did not work. It gave the following error
Something went wrong. Your change may not have been saved. Please try again. There is also a chance that you may need to manually fix and upload the file over FTP.
Please is there an alternative? I don’t want to use FTP
Thank you
- May 3, 2020 at 5:18 pm #126076SushobhanKeymaster
Hello,
It’s not a good idea to edit anything without ftp. If anything goes wrong, like a fatal error, then you can’t recover it from frontend.
To add snippets from wp-admin, use this plugin – https://wordpress.org/plugins/code-snippets/. It’s much better than editing theme’s functions.php using theme editor option.
Finally, the error you are seeing, is not related to the code. If possible use the plugin I mentioned or ftp.
Thanks! - May 7, 2020 at 11:22 am #127874eguareoneParticipant
Hello Sushobhan
Thanks for the heads up and all your help so far. I finally tried the code, The logout redirection worked but not as you expected it to. When the vendor logs out from Store Manager, It gives them a prompt, something like “Do You really want to logout from “Website Url”? On confirmation, it redirects to the wordpress admin Login Url instead of the abaaexpress.com.ng/seller-login/Please I really need help with this as i’m not good with codes. Thanks again
- May 7, 2020 at 12:27 pm #127898SushobhanKeymaster
It should work without the confirmation. I have again tested it on my local setup. Please check if you have pasted the complete code or not. Where you are pasting the code in functions.php or using the snippet plugin? Please send me a snapshot of the portion of the code.
Alternatively, could you please provide me a temporary ftp along with a vendor access to debug this?
Thank You! - May 8, 2020 at 3:03 am #128180eguareoneParticipant
Hi,
I prefer the alternate measure. Please send me an email to abaaexpress@gmail.com so that I can forward the FTP and Vendor Login Access. Thanks
- June 29, 2020 at 6:58 pm #145028server.monks123Participant
Hello Sushobhan
I also tried the code, The logout redirection worked but wen the vendor logs out from Store Manager, It gives them a prompt, something like “Do You really want to logout from “Website Url”? On confirmation, it redirects to the wordpress admin Login Url instead of the https://inditribes.co.in
Please help me outAttachments:
You must be logged in to view attached files. - July 2, 2020 at 7:48 pm #145718SushobhanKeymaster
Hi,
Could you please send me the code snippet that you are using?
Thanks! - July 2, 2020 at 10:21 pm #145770server.monks123Participant
add_filter( ‘wcfm_logout_url’, function( $logout_url ) {
if ( wcfm_is_vendor() ) {
return ‘https://inditribes.co.in/’;
}
return $logout_url;
} );
add_filter( ‘woocommerce_get_endpoint_url’, function($url, $endpoint, $value, $permalink) {
if ( $permalink === ‘https://inditribes.co.in/’ ) {
return add_query_arg( ‘wcfm_logout’, ‘yes’, $permalink );
}
return $url;
}, 10, 4 );
function redirect_page() {
global $wp;
if ( ! empty( $_REQUEST[‘wcfm_logout’] ) && ! empty( $_REQUEST[‘_wpnonce’] ) && wp_verify_nonce( sanitize_key( $_REQUEST[‘_wpnonce’] ), ‘customer-logout’ ) ) {
wp_safe_redirect( str_replace( ‘&’, ‘&’, wp_logout_url( esc_url_raw( ‘https://inditribes.co.in/’ ) ) ) );
exit;
}
}
add_action( ‘template_redirect’, ‘redirect_page’ ); - July 4, 2020 at 8:54 pm #146104SushobhanKeymaster
Hi,
The code seems correct. Not sure why it is behaving unexpectedly!
Would you be comfortable sharing temporary backend access to your site, to debug this further?
When sharing the access, please don’t forget to mark the reply as private.
Thank you!
- AuthorPosts
- You must be logged in to reply to this topic.