Jump to content

Tectonic

New Members
  • Posts

    1
  • Joined

  • Last visited

Everything posted by Tectonic

  1. Hello all! So glad I found this forum. I would appreciate some assistance please. I'm working on a filter for a Custom Post Type . I need it to filter the list depending on the user's role. The way this should work is the following... * Users in roles "formusers1" and "formusers2" can post. Users can only see their own posts. * Users in role "formchecker1" can see all posts assigned role "formusers1' and can approve each post. * Users in role "formchecker2" can see all posts assigned role "formusers2' and can approve each post. * Users in roles "formsupervisor" and "administrator" can see everyone's posts. So far I can filter by roles "formusers1" and "formusers2" using `$query->set('author', $current_user->ID);` . However, when try to filter the list for role "formchecker1" I see posts from all roles. What am I doing wrong? Here's the rest of the code. Thanks for checking out! ``` add_action('pre_get_posts', 'filter_posts_list'); function filter_posts_list($query) { //GLOBAL VARIABLES global $pagenow, $typenow; //MY VARIABLES global $current_user; get_currentuserinfo(); //FILTERING if (current_user_can('formchecker1') && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt' ) { $query->set('author', 'formusers1'); } if (current_user_can('formchecker2') && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt' ) { $query->set('author', 'formusers2'); } if ((current_user_can('formusers1') || current_user_can('formusers2')) && ('edit.php' == $pagenow) && $typenow == 'mycustomcpt') { $query->set('author', $current_user->ID); } } ```
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.