2

I have a role called Content Editor and 2 users Chang and Liang with that same role.

They can both add/edit their own content. The role permission is set in such a way that they can only edit own content.

However, when Chang navigates to /admin/content, this user can see all the contents written by all the users.

How to restrict Chang so that he can see only the contents he has written when visiting the /admin/content link?

1

I created a sandbox-module for that called Content Admin Access Maybe this is what you are looking for.

With Content Admin Access you can set permissions to show or hide others content in the admin/content overview.

Enabling this module will by default show only your own content in the admin/content overview.

0

I'm assuming that with "see all the contents" you mean "can browse the actual content" (and not something like "the list of nodes with their titles").

In that case, you might consider using the Rules module. Basically your rule would look like something like this:

  • Event: Content is viewed
  • Condition: (User has role = Content Editor) AND (node:author not equal to site:current-user)
  • Action: Page redirect (to some appropriate node that seems appropriate)
0

Install Administration Views.

Replaces administrative overview/listing pages with actual views for superior usability.

You can then alter the view that displays node listing to include content by currently logged in user etc.

  • yes thanks, BUT it restricts the content for Admin user as well. eg: user1 should see all the contents in the list but with this approach even for user1 it shows only the contents the user created – user12947 Jun 17 '15 at 7:59
  • Implement hook_views_pre_view where you add the user id as an arg, except if user is admin. Remove the default 'from logged in user' bit in the views contextual filter and if not present then view all. – J. Reynolds Jun 17 '15 at 11:05
0

We can use hook_query_TAG_alter to filter content at admin/content page

/**
 * Implement hook_query_TAG_alter()
 * Need to filter out nodes from admin/content page.
 */
function hook_query_node_admin_filter_alter(QueryAlterableInterface $query) {
  global $user;
  if ($query->hasTag('node_admin_filter')) {
    $query->condition('uid', $user->uid);
  }
}

We can bypass super admin by adding condition.

Thanks, Devendra

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy