When user posts some node, he saw this message 3 times. How to correct this?
The message is - "The post has been submitted for moderation and won't be listed until it has been approved."

Comments

pwolanin’s picture

Priority: Normal » Minor

This is becaase of a quirk in drupal_set_message(). It's harmless, but can be annoying. You can change this by overriding the theme function:


function theme_modr8_message($teaser = FALSE, $nodetype = 'page', $op = 'view') {
  if ($teaser) {
    return ' <div class="marker">'. t('pending moderation') .'</div>';
  }
  else {
    drupal_set_message(t('The post has been submitted for moderation and won\'t be accessible until it has been approved.'));
    return '';
  }
}

inforeto’s picture

How about theming the same message when appearing in odd places, like in search results, or in admin/logs/status after a manual cron?
Are these cases related to modr8? It shouldn't appear even a single time on these pages.

pwolanin’s picture

The patch here: http://drupal.org/node/123994

Seems to help this problem as well.

alanburke’s picture

Hi Pwolanin,

I've tested the patch over at http://drupal.org/node/123994.

It doesn't help me out in this instance.
[I have some complicated (read: not perfect) tpl.php files, so my previews don't work at all, but thats for another day and another issue]

Overriding the theme function will help to a degree, in that I can disable the drupal_set_message call.

It seems that the theme function is being called multiple times.
I think its at the 'view' op, line 126 of the modr8.module.

In some cases the 'view' op and 'insert' op are both being called, hence even more instances of drupal_set_message.

I have a suspicion that the reason for the multiple appearances of the message is that I have about 6 different 'roles' on the site.
But I'm not sure.

Happy to keep testing!

Alan

memenoje’s picture

Title: 3 times messages » 5 times messages

Hi Pwolanin,

I change theme function in modr8.module, but now this message (The post has been submitted....) 5 times is displayed :-(

personman’s picture

I'm also having this problem using 2.2. I'm using modr8 with the Classified Ads module and after submitting an ad, I see the message 3 times.

personman’s picture

Here's my ugly little solution for this:

function theme_modr8_message($teaser = FALSE, $nodetype = 'page', $op = 'view') {
  global $modr8messagedone;
  if ($teaser) {
    return ' <div class="marker">'. t('pending moderation') .'</div>';
  }
  else {
    if (!empty($modr8messagedone))
    {
      $modr8messagedone = true;
      drupal_set_message(t('The post has been submitted for moderation and won\'t be accessible until it has been approved.'));
    }
    return '';
  }
}
personman’s picture

Sorry, that should be empty, not !empty. And there are still 2 of the messages, but it's better than 3 or 5.

pwolanin’s picture

better to use a static variable than a global, I think.

gmayes’s picture

Thanks personman for sharing something a bit better!

Has anyone figured out how to remove this message entirely from the search results page and any other places where it shouldn't be? I tried the patch listed earlier to no avail.

Best, Geoff

halfiranian’s picture

I would really appreciate any ideas on how to get rid of messages in the wrong place/multiple messages.

Thanks

Biteme’s picture

I got around this with a theme function in template.php that stops all 5 error messages. An info message still shows up, so I figured I could do without them:

function themename_modr8_message($teaser = FALSE, $nodetype = 'page', $op = 'view') {
  switch ($op) {
    case 'view': // work around a bug where 5 error messages are listed on submit
      if (!$teaser) return '';
      break;
  }
  return theme_modr8_message($teaser, $nodetype, $op);
}
.carey’s picture

This code works great, Biteme.

Can you, or anyone else, help me to get it to work with more than one content type. It seems when I duplicate the php code in my template.php file and change the content type I get a "duplicate code" error message.

jody lynn’s picture

Title: 5 times messages » Extra drupal_set_messages
Version: 5.x-2.2 » 5.x-2.3
Status: Active » Needs review
StatusFileSize
new1.03 KB

Ok, let's get this patched in the module so we don't have to do these theme overrides to get around the bug. This patch is working for me.

pwolanin’s picture

ok, that's a nice simple fix.

pwolanin’s picture

Status: Needs review » Fixed
StatusFileSize
new2.06 KB

better version, committed to 5.x. Please test: http://drupal.org/node/244303

pwolanin’s picture

StatusFileSize
new2.11 KB

patch committed to 6.x (HEAD)

Anonymous’s picture

Status: Fixed » Closed (fixed)

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