Last active
June 24, 2016 09:42
-
-
Save bentasm1/a5950f0e5aeaeb034080 to your computer and use it in GitHub Desktop.
Redirect Vendors to Vendor Dashboard @ login
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Redirect Vendors to Vendor Dashboard on Login */ | |
add_filter('woocommerce_login_redirect', 'login_redirect', 10, 2); | |
function login_redirect( $redirect_to, $user ) { | |
// WCV dashboard -- Uncomment the 3 lines below if using WC Vendors Free instead of WC Vendors Pro | |
// if (class_exists('WCV_Vendors') && WCV_Vendors::is_vendor( $user->id ) ) { | |
// $redirect_to = get_permalink(WC_Vendors::$pv_options->get_option( 'vendor_dashboard_page' )); | |
// } | |
// WCV Pro Dashboard | |
if (class_exists('WCV_Vendors') && class_exists('WCVendors_Pro') && WCV_Vendors::is_vendor( $user->id ) ) { | |
$redirect_to = get_permalink(WCVendors_Pro::get_option( 'dashboard_page_id' )); | |
} | |
return $redirect_to; | |
} |
Thanks Ben! I've merged yours so that it's now the standard way to do it. It's updated across all the sites as well. :)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
(this has been merged into the above now)
Alt version that doesn't hard code the URL - comment in out the right bit for WCV pro / regular.
No need for the else block either - think it's better to return what comes in untouched - by default it will be my-account, but could be anything else if the url has been amended etc.