Conditional menus not visible after updating role via php
-
Hello,
I encountered the following problem: I have conditional menus only visible for logged-in users with a specific UM-custom role (let’s say “UMroleA”). When I update a user to this role UMroleA via WPadmin interface, he/she is able to see the conditional menus for this user (this is the correct behaviour).
However, if I update the role via php custom page using the code below, the conditional menus are not visible for the user. Only menu tabs for his previous role are visible. What is surprising is that the restricted pages to role UMroleA are accessible (directly using URL links).
Have you any ideas of this behaviour? Is this a bug or a problem from me? Can I fix it?
Code to update user role :
$user = new WP_User($user_id);
// either add_role or set_role
$user->add_role(“UMroleA”);
// OR
$user->set_role(“UMroleA”);I’m using: WordPress 5.8.1, Ultimate Member 2.2.5, theme Spacious.
- The topic ‘Conditional menus not visible after updating role via php’ is closed to new replies.