We have a web page which links users to CiviCRM profiles, to allow them to update their details. After saving, the profile redirects users to the original web page.

Since the original page is not in CiviCRM, the 'Thank you, your details have been updated' message does not appear on the page. However, the next time the user visits a CiviCRM page, that stored message does appear.

We are using Drupal, but I imagine the issue is the same for other CMSes.

TL;DR How do we render the the status message on the non-Civi page?

One idea would be to create a custom block in a Drupal with some code along the lines of:

$session = CRM_Core_Session::singleton();
$messages = $session->getStatus(TRUE);
if (count($messages)){
  foreach ($messages as $message) {
    $ds = 'status';
    if ( !empty($message['type']) && $message['type'] == 'error') { $ds = 'error'; }
    drupal_set_message(t('<strong>@title</strong> @message', array('@title' => $message['title'], '@message' => $message['text'])), $ds);

This accesses the session, gets the messages, and converts them to drupal_set_message messages. Is there a better way?

3 Answers 3



should do the trick. This is implemented for drupal only. I dont think we've figured out how to set messages in WP / Joomla as yet

  • Thanks, I can see this would replace the drupal_set_message part of my code above, but I'd still have to load up the session and call that function inside a loop for each message?
    – John
    Commented May 21, 2015 at 10:11

I couldn't find a way to do what I wanted, so I've created a small Drupal module that renders CiviCRM status messages from the session on non-CiviCRM pages for logged-in users:



Your code looks good to me. One note is that the only required field in a civi message is the text. Everything else (title and type) are optional so you'll want to account for a possibly missing title.

Also ensure your block excludes all paths starting with civicrm!

  • Thanks Coleman - it was already checking for non-Civi paths, but I've added the check for if the title is set. Would this be useful in Core or shall I leave it as a separate monster for the time being?
    – John
    Commented Jul 3, 2015 at 16:11
  • Contributing it as a drupal module seems like a good way forward.
    – Coleman
    Commented Jul 4, 2015 at 2:34
  • Hi Coleman, there's a project application here if you have time to review it =] drupal.org/node/2572677 Many thanks!
    – John
    Commented Sep 22, 2015 at 13:53

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.