Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
ts.newlists

Filter posts, or only allow inline editing for certain posts on screen

Hi,

I have a workflow problem and I’m not sure it can be solved with the plugin.

Essentially, my client wants to be able to have editors

– create posts for their site,
– mark certain of said posts with a custom field or a category that suggests this post to editors of other sites
– allow other people to edit an additional custom field or an additional category that indicates if that post is supposed to be published on their site, too.

Problem is that it’s impossible in the WP rights system to limit people with “edit published posts” capability to actually only be able to change a category or yes/no custom field.

Using a combination of custom code removing the quick edit and bulk edit forms, as well as removing the submit-div on the single edit screen, for certain user groups – and AC Pro inline editing I was able to create a setup approximating the third above aspect.

The conditional (second) aspect above is, apparently, trickier – hence my question:

a) is it possible to selectively allow inline editing in a post list based on a condition like a “yes” on a ACF yes/no field or a category assigend to the post (eg “recommendation”)?

or b) is it possible to have a default filter for the post edit screen for a specific user role that will only allow that user role to see posts with a “yes” in the ACF field or with the specfic category, but not posts without either. As long as the user group would not be able to see non-recommended posts, the inline editing function could be displayed on all displayed posts (already filtered).

Thanks for your help!

6 years, 2 months ago
ts.newlists

Never mind, I found a solution based on b) above, I post it below, maybe it will help someone.

Based on a post on wp-stackexchange – https://wordpress.stackexchange.com/questions/9353/is-there-a-wordpress-hook-to-filter-the-edit-posts-view – I’m using the code below to filter the edit post screen for certain user roles and post types by adding query vars for the meta data to the query.

add_filter( 'parse_query', 'filter_post_edit_screen' );
function filter_post_edit_screen($query) {
  global $pagenow;

  if (is_admin() && $pagenow=='edit.php') {
      
      if (current_user_can('[role or capability]')) {
          
          if ( $query->query_vars['post_type'] == '[abc]'
            || $query->query_vars['post_type'] == '[def]'
            ) {

                $query->query_vars['meta_key'] = '[meta_key]';
                $query->query_vars['meta_value'] = '[meta_value]';
         }
      }      
   }
    return $query;
}
6 years, 2 months ago

You must be logged in to reply to this topic.