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('<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?