Skip to content

Instantly share code, notes, and snippets.

@stephanieleary
Last active October 10, 2016 21:40
Show Gist options
  • Save stephanieleary/46ac65a5498dcd6f6643df93d1314d8b to your computer and use it in GitHub Desktop.
Save stephanieleary/46ac65a5498dcd6f6643df93d1314d8b to your computer and use it in GitHub Desktop.
Redirect user to primary blog dashboard if not superadmin or not allowed on this blog
<?php
add_filter( 'login_redirect', 'tees_subsite_login_redirect', 100, 3 );
function tees_subsite_login_redirect( $redirect_to, $request_redirect_to, $user ) {
if ( !is_user_member_of_blog() || ( is_main_site() && !is_super_admin() ) ) {
$redirect_to = get_admin_url( get_userdata( $user->ID )->primary_blog );
}
return $redirect_to;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment