Skip to content

Instantly share code, notes, and snippets.

@bentasm1
Created May 27, 2016 19:36
Show Gist options
  • Save bentasm1/a2c57c7b633d7dbc4a39043aa31a9f59 to your computer and use it in GitHub Desktop.
Save bentasm1/a2c57c7b633d7dbc4a39043aa31a9f59 to your computer and use it in GitHub Desktop.
WC Vendors - Redirect even from wp-login.php for the role vendor
/* WC Vendors - Redirect even from wp-login.php for the role vendor */
add_action( 'admin_init', 'wcvendors_wplogin_redirect' );
function wcvendors_wplogin_redirect() {
if ( ! defined( 'DOING_AJAX' ) ) {
$current_user = wp_get_current_user();
$role_name = $current_user->roles[0];
if ( 'vendor' === $role_name ) {
wp_redirect( 'http://yoursite.com/dashboard' );
} // if $role_name
} // if DOING_AJAX
} // wcvendors_wplogin_redirect
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment