I need to customize a module and after an if statement check, refresh the page:

So what I need is to refresh the page right after this and print out a success message.

1 Answer 1


What you can do is still use Rules for this.

  1. Go to your custom rule
  2. Under the Actions section, click Add action
  3. For Select the action to add, choose Page redirect.
  4. For URL, place the internal or absolute path to where the page you want to go to a.k.a. be refreshed.
  5. Then save the action. This solves your problem to refresh the page.
  6. Now we add another action to display a message, click the Add action link again.
  7. For Select the action to add, choose Show a message on the site.
  8. Then place your message then Save.

This way, your actions based on an event is configurable just with Rules. This also opens an opportunity to convert your custom code to respond using Rule Events like to trigger the rule after a node is saved and etc.


This is an option to programatically do the above method.

  1. After the rule invoke method, add the drupal_set_message function
  2. After the drupal_set_message method, you would need to add the drupal_goto function which you will pass a Drupal path or a full URL.