How to check admin right without include pluggable.php
-
Hi Guys,
What is the best way to check if the user has admin right?We googling that the best way to do this is to check the current_user_can(‘manage_options’) but to do this I see that we need to include “pluggable.php”.
I also see that if you installed in a multisite this throws an error in authentication so we inserted the code like this return (is_multisite() || current_user_can(‘manage_options’));
BUT…
Including the file “pluggable.php” we will also define the wp_mail function so other plugins (like wpMandrill) will notify an error.Below our current function
function isAdminUser() { if (!function_exists('wp_get_current_user')) { require_once(ABSPATH . 'wp-includes/pluggable.php'); } return (is_multisite() || current_user_can('manage_options')); }
There is a better way (compatible with multisite and without defining wp_mail) or we have to change our function like this ??
function isAdminUser() { return TRUE; }
Thanks, Alex.
- The topic ‘How to check admin right without include pluggable.php’ is closed to new replies.