Skip to content

Instantly share code, notes, and snippets.

@vdchristelle
Created January 27, 2015 15:09
Show Gist options
  • Save vdchristelle/8af92c45cdd8647ce18a to your computer and use it in GitHub Desktop.
Save vdchristelle/8af92c45cdd8647ce18a to your computer and use it in GitHub Desktop.
Node operation to change the content author to siteowner
<?php
/**
* Implementation of hook_help().
*/
function the_aim_author_change_help($path, $arg) {
switch ($path) {
case 'admin/help#the_aim_author_change':
$output = '<h3>' . t('Add extra bulk operation for content') . '</h3>';
$output .= '<p>Unpublished node created by admin are not accessable for siteowners.<br />Therefore we must change the author of the nodes to siteowner. This module adds the extra bulk update action...</p>';
$output .= '<ul>';
$output .= '<li>Activate the <a href="/admin/modules">module</a></li>';
$output .= '<li><a href="/admin/config/development/performance">Clear cache</a></li>';
$output .= '<li>Bulk update your <a href="/admin/content">nodes</a></li>';
$output .= '<li>Don\'t forget to desactivate the <a href="/admin/modules">module</a> when this magnificent piece of code did it\'s work</li>';
$output .= '</ul>';
return $output;
}
}
/**
* Implementation of hook_node_operations().
*/
function the_aim_author_change_node_operations() {
$operations = array(
'author_update' => array(
'label' => t('Change author to siteowner'),
'callback' => 'node_mass_update',
'callback arguments' => array('updates' => array('uid' => 3)),
),
);
return $operations;
}
name = "Change author to siteowner"
description = "Provides a node operation to change the content author to siteowner"
package = "the AIM"
core = 7.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment