function hook_scheduler_allow_publishing in Scheduler 7
Same name and namespace in other branches
- 8 scheduler.api.php \hook_scheduler_allow_publishing()
Allows modules to prevent publication of a scheduled node.
Modules can implement hook_scheduler_allow_publishing() to prevent publishing of a scheduled node. The node can be scheduled for publishing as usual, and an attempt to publish it will be made during the first cron run after the publishing time. If this hook returns FALSE the node will not be published. Attempts at publishing will continue on each subsequent cron run until this hook returns TRUE.
Parameters
object $node: The scheduled node that is about to be published.
Return value
bool TRUE if the node can be published, FALSE if it should not be published.
1 function implements hook_scheduler_allow_publishing()
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
- scheduler_test_scheduler_allow_publishing in tests/
modules/ scheduler_test.module - Implements hook_scheduler_allow_publishing().
File
- ./
scheduler.api.php, line 107 - API documentation for the Scheduler module.
Code
function hook_scheduler_allow_publishing($node) {
$allowed = TRUE;
// Prevent publication of nodes that do not have the 'Approved for publication
// by the CEO' checkbox ticked.
if ($items = field_get_items('node', $node, 'field_approved')) {
$allowed = !empty($items[0]['value']);
// If publication is denied then inform the user why. This message will be
// displayed during node edit and save.
if (!$allowed) {
drupal_set_message(t('The content will only be published after approval by the CEO.'), 'status', FALSE);
}
}
return $allowed;
}