How to have certain products show for only certain users (Not roles)
How to have certain products show for only certain users (Not roles)
How to have certain products show for only certain users (Not roles)
how to Hide all products except the General Manager role in the WordPress admin panel?
You could try something like the code below. <?php /** * Use the two lines below if the user_id is not available * via get_current_user_id at this point in code execution. * * $user_id = apply_filters( ‘determine_current_user’, false ); * wp_set_current_user( $user_id ); */ $current_user_id = get_current_user_id(); $user_data = get_userdata( $current_user_id ); $user_roles = $user_data->roles; … Read more
Example: add_role(‘student’, __( ‘Student’), array( ‘read’ => true, // Allows a user to read ‘create_posts’ => false, // Allows user to create new posts ‘edit_posts’ => false, // Allows user to edit their own posts ‘edit_others_posts’ => false, // Allows user to edit others posts too ‘publish_posts’ => false, // Allows the user to publish … Read more
Filtering custom post admin listing page elements based on acf user field
Custom Admin Menu Report for Specific User ID
User roles empty
This is working perfectly for me but, is this an acceptable WP way to do it? If it works and you didn’t modify core or internal WP private objects then the way you did it is fine. I’m asking because somewhere I read you should not use wp_get_current_user for something like this but since it’s … Read more
Problems with the navigation menu
The add_role function should give you what you’re looking for. Here’s an example of using it to add a new role that allows the user to upload and delete media: function wpse413985_add_role(){ /* Check if the role already exists, since we don’t need to add it again every time the site loads. */ if ( … Read more