hook node access drupal 7, not working when the node is updated I have created a module using the following code.

&lt;?php
global $user;

if (in_array('contributor', array_values($user-&gt;roles))) {
    function publishEntities_node_access($node, $op, $account) {
        if (in_array('article', node_permissions_get_configured_types())) {
            if($node-&gt;status==0) {
                if ($op == 'update') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
                if ($op == 'delete') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
            }
            elseif($node-&gt;status==1) {
                if ($op == 'update') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
                if ($op == 'delete') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
            }
        }

        if (in_array('events', node_permissions_get_configured_types())) {
            if($node-&gt;status==0) {
                if ($op == 'update') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
                if ($op == 'delete') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_ALLOW;
                    }
                }
            }
            elseif($node-&gt;status==1) {
                if ($op == 'update') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
                if ($op == 'delete') {
                    if ($account-&gt;uid == $node-&gt;uid) {
                        return NODE_ACCESS_DENY;
                    }
                }
            }
        }
    }
}


The module does not work after the node is being updated.

Can anybody help me to make this module work as expected?
I cant seem anything that stands out as a problem other than maybe moving:

if (in_array('contributor', array_values($user-&gt;roles))) {


Into the hook_node_access and change $user for $account.

However when troubleshooting problems like this I would firstly ensure you do not have any other access control modules enabled, they can often override each other depending on the modules weight in the system table.

Turn off all modules but core and try isolate parts of your code to get it working bit by bit. For example start off initially with:

function publish_entities_node_access($node, $op, $account) {

        if ($op == 'view') {
            if ($account-&gt;uid == $node-&gt;uid) {
                  return NODE_ACCESS_ALLOW;
            }
            else {
                  return NODE_ACCESS_DENY;
            }
        }
 }


This code should work and easy to test, if you are not the author of the node then you will not be able to view it. You can then start adding on your additional if statements above until you run into a problem. 

You can also install the devel module to nicely output the array's to ensure the values you are using conditionally in your code are available.