I would like to provide users with role-A and role-B the ability to edit their own published and unpublished content. I've installed the Content Access Module and seems impossible to make this without coding. Does anyone know how to solve with code?


2 Answers 2


I am not sure about your exact requirement. If you want to list all contents created by current user with an edit link, my suggestion to make try with views.

  1. Give Edit Own Content permission to your needed roles for all content types in Home » Administration » People » Permissions.
  2. Create a view with content of all.
  3. Add title in fields (or the fields you want).
  4. If you want to give an edit link , add Content:Edit Link.
  5. In views contextual filter add Content:Author uid = User ID from logged in user (Refer here).
  6. Change format to Table (Only title and edit link is there this gives a nice formatting).

Hope this will help you.

  • With this i can provide my actually view with and edit button but it doesn't change the permission. When i click on edit i see You are not authorized...
    – Emanuele
    Nov 21, 2015 at 10:30
  • Give Edit Own Content permission to needed roles for all content types in Home » Administration » People » Permissions.
    – Abin
    Nov 21, 2015 at 10:50
  • Yew i've all permissions set under node
    – Emanuele
    Nov 21, 2015 at 11:04
  • The only way i've found to see the Edit tab is to check the Bypass the control access to content, first check under Node in permissions page... but it's not a really good solution
    – Emanuele
    Nov 21, 2015 at 11:07

You can try this in your own module:

function MODULE_permission() {
    return array(
        'edit own unpublished content' => array(
            'title' => t('Edit own unpublished content'),
            'description' => t('Allow user to edit own unpublished content.'),

function MODULE_node_access($node, $op, $account) {
    if (user_access("edit own unpublished content") && $op == "update" && $node->status == 0 && $node->uid == $account->uid) {
        return NODE_ACCESS_ALLOW;

It will add a permission that is applicable to all nodes. If you want to set it for a specific bundle only you will have to expand on it a bit.

  • It does not work. Even after run permissions rebuilt
    – Emanuele
    Nov 21, 2015 at 10:28
  • Try on a clean install to assure yourself that it works, then look at module calling order as it may have an effect. Nov 22, 2015 at 12:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.