Answers.Body: <p>CRM_Utils_System::setUFMessage($message)</p>
  
  <p>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</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-21T10:11:25.703Z
Answers.Text: 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?
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-20T13:56:14.313Z
Answers.LastActivityDate: 2015-05-20T13:56:14.313Z
Answers.UserDisplayName: Donald Lobo
Answers.Body: <p>Your code looks good to me. One note is that the only required field in a civi message is the <code>text</code>. Everything else (title and type) are optional so you'll want to account for a possibly missing title. </p>
  
  <p>Also ensure your block excludes all paths starting with civicrm!</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-03T16:11:03.427Z
Answers.Text: 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?
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-04T02:34:28.207Z
Answers.Text: Contributing it as a drupal module seems like a good way forward.
Answers.UserDisplayName: Coleman
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-09-22T13:53:12.367Z
Answers.Text: Hi Coleman, there's a project application here if you have time to review it =] https://www.drupal.org/node/2572677 Many thanks!
Answers.UserDisplayName: John
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-02T00:15:46.310Z
Answers.LastActivityDate: 2015-07-02T00:15:46.310Z
Answers.UserDisplayName: Coleman
Answers.Body: <p>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:</p>
  
  <p><a href="https://www.drupal.org/project/civicrmstatusmessage" rel="nofollow">https://www.drupal.org/project/civicrmstatusmessage</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-07-01T13:46:38.503Z
Answers.LastActivityDate: 2016-06-23T12:33:55.820Z
Answers.LastEditDate: 2016-06-23T12:33:55.820Z
Answers.UserDisplayName: John
Body: <p>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.</p>
  
  <p>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.</p>
  
  <p>We are using Drupal, but I imagine the issue is the same for other CMSes.</p>
  
  <p>TL;DR
  How do we render the the status message on the non-Civi page?</p>
  
  <hr>
  
  <p>One idea would be to create a custom block in a Drupal with some code along the lines of:</p>
  
  <pre><code>civicrm_initialize();
  $session = CRM_Core_Session::singleton();
  $messages = $session-&gt;getStatus(TRUE);
  if (count($messages)){
    foreach ($messages as $message) {
      $ds = 'status';
      if ( !empty($message['type']) &amp;&amp; $message['type'] == 'error') { $ds = 'error'; }
      drupal_set_message(t('&lt;strong&gt;@title&lt;/strong&gt; @message', array('@title' =&gt; $message['title'], '@message' =&gt; $message['text'])), $ds);
    }
  }
  </code></pre>
  
  <p>This accesses the session, gets the messages, and converts them to drupal_set_message messages. Is there a better way?</p>
  
Tags: <cms-integration>
Title: How to display CiviCRM status messages on CMS pages
ThreadText: # How to display CiviCRM status messages on CMS pages
  
  (Asked by: username_0 on 2015-05-20)
  
  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:
  civicrm_initialize();
  $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('@title @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?
  
  **Tags:** cms-integration
  
  
  ---
  
  ## 3 answers
  
  ### Answer by username_0 on 2015-07-01. Score: 5 | Accepted answer
  
  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:
  
  <https://www.drupal.org/project/civicrmstatusmessage>
  
  
  ---
  
  ### Answer by username_1 on 2015-05-20. Score: 5
  
  CRM\_Utils\_System::setUFMessage($message)
  
  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
  
  > **Comments:**
  > **username_0**: 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?  
  
  ---
  
  ### Answer by username_2 on 2015-07-02. Score: 1
  
  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!
  
  > **Comments:**
  > **username_0**: Thanks username_2 - 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?  
  > **username_2**: Contributing it as a drupal module seems like a good way forward.  
  > **username_0**: Hi username_2, there's a project application here if you have time to review it =] https://www.drupal.org/node/2572677 Many thanks!  
  
  ---
  
  