If you have a member-based website and don't want to provide access to the back end, the following filter will redirect users upon login to the front page.
Copy and paste the WordPress function into your theme's functions.php
file or, if you sensibly have one installed, your custom functions plugin.
1
<?php
2
/*
3
Redirect Subscriber WordPress Users to Front Page After Login
4
http://www.beliefmedia.com/code/wp-snippets/redirect-users
5
*/
6
7
8
9
if($user->has_cap( 'administrator')) {
10
11
} else {
12
13
}
14
}
15
return $url;
16
}
17
The next function will redirect a user upon requesting an admin page.
1
<?php
2
/*
3
Redirect Logged in Users to Front Page
4
http://www.beliefmedia.com/code/wp-snippets/redirect-users
5
*/
6
7
8
9
10
exit;
11
}
12
}
13