This is what I used, make your edits as needed.
add_filter( 'if_menu_conditions', 'my_new_menu_conditions' );
function my_new_menu_conditions( $conditions ) {
$conditions[] = array(
'name' => 'User is Custom Role', // name of the condition
'condition' => function() {
global $current_user;
if( is_user_logged_in() ) return in_array( 'custom-role', $current_user->roles );
return false;
}
);
return $conditions;
}
Plugin Author
Andrei
(@andreiigna)
Hi speedfreakhorror,
Thank you for using the plugin. Also sorry for the delayed answer..
I hope the solution posted by arudd works. That’s the template you need to use, change the ‘custom-role’ with the role added by the plugin, then add this code in theme’s functions.php file
Hi Andrei,
please update the plugin that gets all possible conditions to work with this good plugin.
I tried this but its not working as expected
add_filter( 'if_menu_conditions', 'custom_if_menu_conditions' );
function custom_if_menu_conditions( $conditions ) {
foreach (get_editable_roles() as $role_name => $role_info){
$conditions[] = array(
'name' => $role_info['name'],
'condition' => function() {
global $current_user;
if( is_user_logged_in() ) return in_array( $role_name, $current_user->roles );
return false;
}
);
}
return $conditions;
}