How to programmatically refresh the current page? 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.
What you can do is still use Rules for this.


Go to your custom rule
Under the Actions section, click Add action
For Select the action to add, choose Page redirect.
For URL, place the internal or absolute path to where the page you want to go to a.k.a. be refreshed.
Then save the action. This solves your problem to refresh the page.
Now we add another action to display a message, click the Add action link again.
For Select the action to add, choose Show a message on the site.
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.


After the rule invoke method, add the drupal_set_message function
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.