Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just to add some more info - BrainV helped me develop the following code for a custom module - called publishtrigger here. I wanted the approve button to publish the Player node and then assign it to the "contentadmin" user, which has ID 6 in my case...</p> <pre><code>&lt;?php /** * Implementation of hook_perm(). */ function publishtrigger_perm() { return array('approve nodes'); } /** * Implementation of hook_menu(). */ function publishtrigger_menu() { $items['approve/%'] = array( 'title' =&gt; 'Approve', 'page callback' =&gt; 'publishtrigger_approve_node', 'page arguments' =&gt; array(1), 'access arguments' =&gt; array('approve nodes'), 'type' =&gt; MENU_CALLBACK, ); return $items; } /** * Implementation of hook_link(). */ function publishtrigger_link($type, $object, $teaser = FALSE) { // Show this link at the bottom of nodes of the Player type which are not yet // owned by contentadmin (UID 6). if ($type == 'node' &amp;&amp; $object-&gt;type == 'player') { // Make sure user has permission to approve nodes. if (user_access('approve nodes')) { $links = array(); if ($object-&gt;uid != 6 || $object-&gt;status == 0) { // Node is not owned by contentadmin (UID 6), and therefore not approved. $links['approve_link'] = array( 'title' =&gt; 'Approve', 'href' =&gt; 'approve/' . $object-&gt;nid, ); } else { // Node is already approved $links['approve_link'] = array('title' =&gt; 'Already approved'); } return $links; } } } /** * When this code is run, adjust the owner of the indicated node to 'contentadmin', * UID 6. * * @param $nid * The node id of the node we want to change the owner of. */ function publishtrigger_approve_node($nid) { // Load the node. $node = node_load($nid); // Set the UID to 6 (for contentadmin). $node-&gt;uid = 6; // Publish the node $node-&gt;status = 1; // Save the node again. node_save($node); // Go back to the node page drupal_goto($node-&gt;path); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload