current_user_can( ‘edit_user’ ) does not work

Question

I don´t clearly understand why this code does not work :

//Front-end profile page
global $current_user;
if ( current_user_can( 'edit_user') ) { ... }

$current_user output : ["allcaps"]=> array(6) { ["read"]=> bool(true) ["level_0"]=> bool(true) ["edit_user"]=> bool(true) ["view_admin_dashboard"]=> bool(true) ["subscriber"]=> bool(true) ["client"]=> bool(true) }

So, that is in the list !

even if I do this :

$role = get_role('client');
$role->add_cap('edit_user');
global $current_user;
if ( current_user_can( 'edit_user') ) { ... }

that does not work as well.

But with the capability ‘read’, that works perfectly.

Someone can help me and explain what happens ?

0
J.BizMai 2 months 0 Answers 12 views 0

Leave an answer