Answers.Body: <p>Xavier's answer is generally right but because you are in the context of a form I advise <em>don't</em> use the function <code>CRM_Utils_System::redirect</code> because that is a rather blunt instrument, and breaks pop-ups and other ajax-based forms (which don't follow the normal round-trip webpage lifecycle). Instead from your hook you can call <code>CRM_Core_Session::singleton()-&gt;pushUserContext($urlYouWant);</code> and the form controller will take care of doing the actual redirect or other appropriate action.</p>
  
  <p>So from your hook you'd do:</p>
  
  <pre><code>$url = CRM_Utils_System::url('civicrm/my/path', 'argumet=1');
  CRM_Core_Session::singleton()-&gt;pushUserContext($url);
  CRM_Core_Session::setStatus(ts('Your foo has been barred'), ts('Saved'), 'success');
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-10T00:19:08.657Z
Answers.LastActivityDate: 2015-05-10T00:19:08.657Z
Answers.UserDisplayName: Coleman
Answers.Body: <p>You can redirect using the </p>
  
  <pre><code>CRM_Utils_System::redirect($urlyouwant)
  </code></pre>
  
  <p>and use </p>
  
  <pre><code>CRM_Utils_System::url
  </code></pre>
  
  <p>to build the url itself. </p>
  
  <p>you can as well display pop up messages using CRM.alert() or CRM.status()</p>
  
  <p>That page describes the options or how to call them from php too:
  <a href="http://wiki.civicrm.org/confluence/display/CRMDOC/Notifications+and+Confirmations" rel="nofollow">http://wiki.civicrm.org/confluence/display/CRMDOC/Notifications+and+Confirmations</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2015-05-09T09:49:40.100Z
Answers.LastActivityDate: 2015-05-09T09:49:40.100Z
Answers.UserDisplayName: Xavier
Body: <p>I'm writing an extension implementing hook_civicrm_post to move contributions from individual to household if the individual is part of a household. However, I'd like the form to either redirect to the HOUSEHOLD summary or to display something about the household in the Successfully saved status message popup so the user doesn't think the contribution entry failed.</p>
  
  <p>Any ideas how I can do either of those things from the extension?</p>
  
Tags: <extension><hooks><redirect>
Title: Hook to change the Success message after CiviCRM submits a form?
ThreadText: # Hook to change the Success message after CiviCRM submits a form?
  
  (Asked by: username_0 on 2015-05-09)
  
  I'm writing an extension implementing hook\_civicrm\_post to move contributions from individual to household if the individual is part of a household. However, I'd like the form to either redirect to the HOUSEHOLD summary or to display something about the household in the Successfully saved status message popup so the user doesn't think the contribution entry failed.
  
  Any ideas how I can do either of those things from the extension?
  
  **Tags:** extension, hooks, redirect
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_2 on 2015-05-09. Score: 3 | Accepted answer
  
  You can redirect using the 
  CRM_Utils_System::redirect($urlyouwant)
  
  and use 
  CRM_Utils_System::url
  
  to build the url itself. 
  you can as well display pop up messages using CRM.alert() or CRM.status()
  That page describes the options or how to call them from php too:
  http://wiki.civicrm.org/confluence/display/CRMDOC/Notifications+and+Confirmations
  
  
  ---
  
  ### Answer by username_1 on 2015-05-10. Score: 4
  
  username_2's answer is generally right but because you are in the context of a form I advise don't use the function CRM_Utils_System::redirect because that is a rather blunt instrument, and breaks pop-ups and other ajax-based forms (which don't follow the normal round-trip webpage lifecycle). Instead from your hook you can call CRM_Core_Session::singleton()->pushUserContext($urlYouWant); and the form controller will take care of doing the actual redirect or other appropriate action.
  So from your hook you'd do:
  $url = CRM_Utils_System::url('civicrm/my/path', 'argumet=1');
  CRM_Core_Session::singleton()->pushUserContext($url);
  CRM_Core_Session::setStatus(ts('Your foo has been barred'), ts('Saved'), 'success');
  
  
  ---
  
  