WordPress: Prevent access to /wp-admin/

This little handler will also prevent access to profile and dashboard unless you are an admin.

It is handy if you're not using WordPress to handle your users.

function prevent_admin_access() {
if (strpos(strtolower($_SERVER['REQUEST_URI']), '/wp-admin') !== false && !current_user_can('administrator')) {
wp_redirect(get_option('siteurl'));
}
}

add_action('init', 'prevent_admin_access', 0);

Great little snippet. Just paste it into your themes functions.php file and away you go!

[ Source ]

 
Copyright © Twig's Tech Tips
Theme by BloggerThemes & TopWPThemes Sponsored by iBlogtoBlog