For some reason, I can't get working the WordPress function get_editable_roles(). Is there a bug with this? Doesn't mind where I add, in the functions.php, in the index.php, in the top, in the bottom. It always gives the undefined function error.
I added this line of code in Twenty Fifteen theme, in a fresh WordPress install and without any plugin:
$role = get_editable_roles();
It give this error:
Error: Call to undefined function get_editable_roles()...
If I load the user.php file before, then it works:
if (!function_exists('get_editable_roles')) {
require_once(ABSPATH . '/wp-admin/includes/user.php');
}
You should consider to load user.php even you are in admin side, especially you have created a custom admin page like options.
if ( ! function_exists( 'get_editable_roles' ) ) {
require_once ABSPATH . 'wp-admin/includes/user.php';
}
$roles = get_editable_roles();
It is also discussed here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With