Deny wp-admin for non administrator users
Moeilijkheidsniveau: Beginner
This code will redirect users without "user delete permissions" to the home url.
add_action('admin_init','mp_admin_init'); // Deny wp-admin for loggedin non administrator users function mp_admin_init() { require_once(ABSPATH . WPINC . '/pluggable.php'); $current_user = wp_get_current_user(); $current_user_id = ! empty($current_user) ? $current_user->id : 0; $current_user = new WP_User($current_user_id); if(!$current_user->has_cap('delete_users')) { wp_redirect(get_option('home'),302); die(); } }
- Is de aanpassing voor u wat te lastig? Of heeft u weinig tijd? Laat het door een expert uitvoeren!
* Changelog: changed 301 redirect to 302 redirect to fix browser caching issue when using multiple accounts ( one having adminstrator rights )
Hallo,
Ik vroeg mij af waar je deze code toe moet voegen?
Bvd!
Hallo!
Wat betreft; This code will redirect users without "user delete permissions" to the home url.
Ik zou graag willen weten waar ik deze code toe moet voegen?
Alvast bedankt. Met vriendelijke groet,
Nick.
( wanneer ik de reply functie op jullie website 'gebruik' krijg ik dit: Fatal error: Class 'c_ws_plugin__qcache_utils_urls' not found in /home/mnpress/domains/mijnpress.nl/public_html/wp-content/plugins/quick-cache-comment-garbagecollector/qc-comment-gc.php on line 33 )
Hallo Nick,
bij voorkeur in je thema functions.php file.