• Resolved renburnett

    (@renburnett)


    I’m trying to use the hook site-reviews/review/created to add a simple page refresh upon review creation. what am I doing wrong?

    add_action('site-reviews/review/created', function ($review, $command) {
    	?>
        <script type="text/javascript">          
          
          	console.log('fired');
    	location.reload();
            
        </script>
      <?php
    }, 10, 2);

    I keep getting this error in the console from site-reviews.js:
    Uncaught TypeError: this.response is null

    • This topic was modified 2 years, 2 months ago by renburnett.
    • This topic was modified 2 years, 2 months ago by renburnett.
    • This topic was modified 2 years, 2 months ago by renburnett.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter renburnett

    (@renburnett)

    this ended up working for me:

    /**
     * Runs after a review has been created.
     * @return void
     */
    add_filter('site-reviews/enqueue/public/inline-script/after', function () {
    	return "GLSR.Event.on('site-reviews/form/handle', (data) => {
    		window.location.reload();
    	})";
    });
    Plugin Author Gemini Labs

    (@geminilabs)

    There’s a simpler way: Use the Custom Fields Meta Box to add a field name of “redirect_to” and the URL of the page as the field value.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘trying to refresh page on successful form submission’ is closed to new replies.