Skip to content

Instantly share code, notes, and snippets.

@yratof
Created June 4, 2015 09:30
Show Gist options
  • Select an option

  • Save yratof/c7fef3c1487341566674 to your computer and use it in GitHub Desktop.

Select an option

Save yratof/c7fef3c1487341566674 to your computer and use it in GitHub Desktop.
Woocommerce - Non-admins shouldn't be able to see wordpress
<?php
// Non-admins can't login, they're redirected to the video/videos page,
// which stops them from messing with the website.
$goodbye = site_url();
function force_login_redirect( $redirect_to, $request, $user ) {
return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : $goodbye;
}
add_filter( 'login_redirect', 'force_login_redirect', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment