gmaggio
7/4/2014 - 11:15 PM

[Wordpress] Redirect Non-Admin Users to Homepage After Login ( http://tommcfarlin.com/redirect-non-admin/ )

[Wordpress] Redirect Non-Admin Users to Homepage After Login

( http://tommcfarlin.com/redirect-non-admin/ )

<?php
/**
 * Redirect non-admins to the homepage after logging into the site.
 *
 */
function my_login_redirect ( $redirect_to, $request, $user ) {
	return ( is_array( $user->roles ) && in_array( 'administrator', $user->roles ) ) ? admin_url() : site_url();
} // end my_login_redirect
add_filter( 'login_redirect', 'my_login_redirect', 10, 3 );

// Source: http://tommcfarlin.com/redirect-non-admin/
?>