Skip to content

Instantly share code, notes, and snippets.

@driesd
Last active December 26, 2015 12:59
Show Gist options
  • Save driesd/7155014 to your computer and use it in GitHub Desktop.
Save driesd/7155014 to your computer and use it in GitHub Desktop.
Node operation to change the content author to siteowner
<?php
/**
* Implementation of hook_help().
*/
function bulk_author_change_help($path, $arg) {
switch ($path) {
case 'admin/help#bulk_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 bulk_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 = "Custom"
core = 7.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment