Skip to content Skip to sidebar Skip to footer

Drupal 7 Suppress Your Comment Has Been Queued for Review

When new content is created, Drupal sets this system message:

"[content-type] [content title] has been created."

Is there any way this message tin can be unset or overridden with an Action?

Comments

timd.mackey's picture

Component: Rules Core » Rules Engine

Subscribing. I'd besides like to be able to exercise this, specifically so that I can override the default message when a user saves changes to their account.

kopeboy's picture

Version: 7.x-2.0 » 7.x-2.seven
Component: Rules Engine » Rules Cadre
Issue summary: View changes

Yep delight. Not only this message, but whatsoever message created for the same result we are working on with the Dominion.

If that event has already a bulletin and we set one inside the Rule we will have both :(

Is there some configuration nosotros are missing?

Chewits's picture

Seeking how to solve this issue, too...

Chewits's picture

Torenware's picture

You'd need a custom action to exercise this. This actually isn't that hard to practice.

In YOUR_MODULE.rules.inc:

                                  function YOUR_MODULE_rules_action_info() {    render array(      'clear_messages' => array(         'label' => t('Clear any pending Drupal messages.'),         'parameter' => assortment(           'blazon' => assortment('type' => 'text',                                   'characterization' => t('Message Type'),                                  'clarification' => t('A key like "status", "warning" or "error"')                                 ),         ),         'grouping' => t('YOUR MODULE'),         'base' => 'YOUR_MODULE_action_clear_messages',     ),   ); }  function YOUR_MODULE_action_clear_messages($type) {   //clear messages of $type.   drupal_get_messages($type, True); }                              

I haven't tested this (been a while since I worked on Drupal 7; I'm doing D8 at present), simply this should be close to what you want.

Chewits's picture

Thank you, Rob. I solved my initial problem without Rules, though.
In fact, I needed a bit more - to show unlike status letters depending on whether a content was published or not. It'southward needed for forum topics simply.

Hither is my code:

                /**  * We customize 'Forum topic ... has been created.' message when  * it goes to the blessing queue. This is done in two steps:  *  * 1. Add new condition messages implementing hook_node_insert().  *    This is done for both Published and Unpublished nodes.  *    For Published nodes we but duplicate the quondam bulletin.  *    For Unpublished nodes we inform that the message is waiting for approval.  *  * two. Remove quondam status bulletin implementing hook_form_FORM_ID_alter().  *    We override 'submit' action where we remove old messages in case it  *    matches the pattern '@type %title has been created.'.  *    Nosotros only remove a single match, and then fifty-fifty if we duplicate a message  *    on the starting time footstep, one of them will still be displayed.  *  * Nosotros customize as well the Drupal behavior when a Forum Topic was updated and  * the new revision goes to the Approving Queue. Now it redirects a user to  * the Forum Category and shows the similar condition message to inform the user.  * We apply hook_node_update() for that.  */   /**  * Implements hook_node_insert()  */ function MY_MODULE_node_insert($node) {   /**    * Add custom condition letters when a node is inserted    */   if ($node->blazon == 'forum') {     if ($node->status == NODE_NOT_PUBLISHED) {       drupal_set_message(t('Your forum topic has been queued for review by site administrators and will exist published after approval.'));     }     elseif ($node->status == NODE_PUBLISHED) {       $message = t('@blazon %title has been created.', assortment('@type' => node_type_get_name($node), '%championship' => $node->title));       drupal_set_message($bulletin, 'condition', True);     }   } }   /**  * Implements hook_node_update()  */ function MY_MODULE_node_update($node) {   /**    * If a Forum Topic was updated and the new revision goes to the Approval Queue    * we redirect a user to the Forum Category and bear witness a message to keep him informed.    */   if ($node->type == 'forum') {     if ($node->status == NODE_NOT_PUBLISHED) {       drupal_set_message(t('Your forum topic has been queued for review by site administrators and will be published after approval.'));       drupal_goto('forum/' . $node->forum_tid);     }   } }   /**  * Implements hook_form_FORM_ID_alter().  * @see MY_MODULE_node_insert()  */ function MY_MODULE_form_forum_node_form_alter(&$class, &$form_state, $form_id) {   /**    * Override 'submit' action for 'forum_node_form' form    */   $course['deportment']['submit']['#submit'][] = '_MY_MODULE_form_forum_node_form_submit'; }   /**  * @see MY_MODULE_form_forum_node_form_alter()  */ function _MY_MODULE_form_forum_node_form_submit($form, &$form_state) {   /**    * Remove the old status bulletin 'Forum topic ... has been created.'    */   if (!empty($_SESSION['messages']['status'])) {     $node = $form_state['node'];     $old_message = t('@type %title has been created.', array('@blazon' => node_type_get_name($node), '%championship' => $node->title));     $old_message_key = array_search($old_message, $_SESSION['letters']['status']);          if ($old_message_key !== FALSE) {       unset($_SESSION['letters']['status'][$old_message_key]);              // Reset assortment indexes. Otherwise it doesn't piece of work with some theme templates.       $_SESSION['letters']['status'] = array_values($_SESSION['messages']['status']);              // Remove the empty condition message wrapper if no other messages have been set.       if (empty($_SESSION['messages']['condition'])) {         unset($_SESSION['letters']['status']);       }     }   } }              

Ref (rus): www.ishmuradov.com/page/drupal-7-izmenjaem-statusnye-soobshhenija

Promise this helps someone,
Alexander

Amerie's picture

Hither is code for a Rules activeness to clear all or some messages from the site (specified by blazon and/or regular expression practical to the message text):

                function mymodule_rules_action_info() {    $actions['mymodule_rules_action_clear_messages'] = array(     'label' => t('Clear system letters'),     'parameter' => assortment(       'blazon' => array(         'type' => 'token',         'characterization' => t('Articulate messages of type'),         'options list' => 'mymodule_message_types',         'default value' => 'all',         'optional' => Imitation,       ),       'pattern' => array(         'type' => 'text',         'characterization' => t('Regular Expression'),         'description' => t('If specified, messages of the type specified above will only be cleared if their text matches this design.'),         'optional' => TRUE,       ),     ),     'grouping' => t('System'),   );    return $actions; }  function mymodule_rules_action_clear_messages($type, $pattern) {   if ($blazon == "all") {     $message_type = Goose egg;   }   else {     $message_type = $blazon;   }    // Clear all messages of specified blazon.   $all_messages = drupal_get_messages($message_type);    // If no RE provided, done.   if (empty($all_messages) | !$pattern | $design == "") {     return;   }    // Reset messages that do not lucifer RE.   foreach ($all_messages as $category => $messages) {     foreach ($messages as $message) {       if (preg_match($pattern, $message) != 1) {         drupal_set_message($message, $category);       }     }   } }  function mymodule_message_types() {   return assortment(     'all' => t('All'),     'condition' => t('Status'),     'warning' => t('Alert'),     'error' => t('Error'),   ); }                              

TR's picture

This seems to accept been answered several times already.

Status: Fixed » Airtight (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

bmango's picture

Many thanks for the code in #8. Information technology worked perfectly!

valvoforkeded.blogspot.com

Source: https://www.drupal.org/project/rules/issues/1102916

Post a Comment for "Drupal 7 Suppress Your Comment Has Been Queued for Review"