WordPress User Role Permissions For Custom Post Type
Your function looks generally correct, but there are a couple of small mistakes that need to be addressed. Here’s a corrected version of your code: function control_dfwp($query) { $user = wp_get_current_user(); if (in_array(‘Registered for Portal’, $user->roles)) { $query->set(‘author’, $user->ID); // Use $user->ID instead of $current_user->ID } } add_action(‘pre_get_posts’, ‘control_dfwp’); Here are the corrections: Use $query … Read more