1

I'm building a custom module for a project and would like to display a notification/warning to the user once something happens. For instance, my module would trigger a Mailchimp action. Once I get the Ok from Mailchimp, I'd like to show a message to user, something like using Devel's dvm or dpm function.

How can I accomplish this (preferably without additional modules)?

Thanks in advance.

PS: I could use Devel, but I'd rather disable it in production env.

4
  • Piece of cake if adding 1 module would be acceptable anyway (instead of re-inventing the wheel?), which would enable a zillion of possible scenarios you could cover with it. Let me know if you ever want to consider changing your mind. PS: maybe you should enhance your question to explain why you don't want additional modules? Afraid of modulitis (= way too much modules already)? Commented Aug 15, 2016 at 10:00
  • I want to know about the module @Pierre.Vriens
    – Umair
    Commented Aug 15, 2016 at 13:40
  • @Umair : merci for informing me, but unless the question is adapted, I think I'm not "allowed" (hm, hm) to add my answer. BTW: I'm about to answer your previous (followup) question from some days ago (I think I can get it to work, but need to do some extra checking first ...). Commented Aug 15, 2016 at 14:37
  • This sounds good
    – Umair
    Commented Aug 15, 2016 at 15:26

1 Answer 1

4

drupal_set_message() is what you're looking for.

Sample usage:

drupal_set_message('Mailchimp action is successfully executed.');
2
  • That didn't seem to work... I didn't see the notification on the backend theme nor on the frontend. I've literally done as your example above. Commented Aug 15, 2016 at 9:43
  • Are you sure that the related part of the code is really executed? And please check if in your template page.tpl.php that the messages are printed somewhere like: <?php print $messages; ?>
    – Elin Y.
    Commented Aug 15, 2016 at 10:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.