1

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.

3

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.

Update

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.
3
  • 1
    Thanks Leo, but I'd like it to happen programmatically right after the if statement as I mentioned in the question, can you help me out with that ?
    – user23288
    Sep 6 '15 at 4:45
  • 1
    You're welcome! Absolutely! I have updated my answer. Sep 6 '15 at 5:30
  • 1
    No problem at all bro! Hope it all goes well :) Sep 6 '15 at 5:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy