Hello so I'm using Ultimate Member plugin with S2member pro plugin and ultimate members has their own roles called community roles. Also S2member has their own roles called s2member_level1
i'm trying to combine those 2 that whenever s2member_level1
role has some user ultimate member community role also would change to premium for example. i'm using this code to achieve that.
global $ultimatemember;
$user_id = get_current_user_id();
if( current_user_is(s2member_level1) ) {
update_user_meta($user_id, 'role', 'premium');
} elseif ( current_user_is(s2member_level0) ){
update_user_meta($user_id, 'role', 'member');
} else {
}
It works like if some person has s2member_level1
role than it would update ultimate member role to premium and if S2member_level0
that means member is without membership or its already expired than it would change also ultimate member role back to member
which is subscriber for wordpress role.
Problem: It works only if i refresh wordpress admin panel user section than everything updates if i don't refresh that and user s2member role changed it does not react user can still access to only premium users section but when i refresh or access users wordpress admin panel section all roles that should update without this action updates.
Why this happens and how to fix it?