Check if user is admin by user ID

You worded it as you want to check if user has administrator role. It is considered more proper to check for capability, relevant to specific action. In practice this is usually expressed as current_user_can( ‘manage_options’ ) for current user. For arbitrary user it would be user_can( $user_id, ‘manage_options’ ). Of course this is capability that … Read more

What’s the difference between Role and Meta capabilities; When to use map_meta_cap() filter

difference between Role and Meta capabilities That would be better to ask the compare Role with Capabilities, not just Meta capabilities, but as a simple answer: A Role defines a set of tasks a user assigned the role is allowed to perform. Capabilities are assigned to Roles difference between Meta and Primitive capabilities? Meta capabilities … Read more

wp_update_user not updating

Im using remove_role and then add_role to upgrade a user from one role to another. Here is a function that checks all user within the user role subscriber and upgrade them to editor every hour. /** * Add a cron job that will update * Subscribers to editors. Runs hourly */ add_action(‘check_user_role’, ‘upgrade_user’); function run_check_user_role() … Read more