• Resolved novusstd

    (@novusstd)


    Hello,

    I love you plugin, I want that when approve the review from users, the system automatically send email to the user that his review was approved.

    There are hook or something like this to do that?

    Thanks

    • This topic was modified 6 years, 2 months ago by novusstd.
Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Gemini Labs

    (@geminilabs)

    It is not possible to send the email notification (that you can edit in the Site Reviews settings) when a review is approved.

    However, you can use the transition_post_status WordPress hook to send an email when a review has been approved (i.e. published).

    /**
     * @param string $oldStatus
     * @param string $newStatus
     * @param \WP_Post $post
     * @return void
     * @action transition_post_status
     */
    add_action( 'transition_post_status', function( $newStatus, $oldStatus, $post ) {
        if( in_array( $oldStatus, ['new', $newStatus] )
            || $post->post_type != 'site-review'
            || $post->post_status != 'publish'
        )return;
        $review = apply_filters( 'glsr_get_review', null, $post->ID );
        if( !empty( $review->email )) {
            $subject = '...'; // change this
            $message = '...'; // change this
            $sent = wp_mail( $review->email, $subject, $message );
            if( !$sent ) {
                apply_filters( 'glsr_log', null, 'Something went wrong and WordPress was not able to send the email to: <'.$review->email.'>' );
            }
        }
    }, 10, 3 );

    I suggest you also make use of the SendGrid plugin and service (free if you are sending less than 100 emails a day) for reliable email delivery.

    I will add this feature to the roadmap for a future version.

    • This reply was modified 6 years, 2 months ago by Gemini Labs.
    Thread Starter novusstd

    (@novusstd)

    ok thanks a lot.

    And there is any hook for email the user when he submit a review?

    Something like. Hey man you submit this reviem and now is under approval by adminsitrator, for your review yuo can use this discount code.

    Thanks

    Plugin Author Gemini Labs

    (@geminilabs)

    Please see the “Do something immediately after a review has been submitted” section in the plugin Documentation page (Hooks tab).

    Thread Starter novusstd

    (@novusstd)

    ok so, i have write this code, but i want that whe review was submit, the page refresh. How can i do that?

    • This reply was modified 6 years, 2 months ago by novusstd.
    Plugin Author Gemini Labs

    (@geminilabs)

    Please see the “How do I redirect to a custom URL after a form is submitted?” section in the plugin Documentation page (FAQ tab).

    Plugin Author Gemini Labs

    (@geminilabs)

    FYI:

    /**
     * Runs after a review has been submitted in Site Reviews.
     * @param \GeminiLabs\SiteReviews\Review $review
     * @param \GeminiLabs\SiteReviews\Commands\CreateReview $request
     * @return void
     */
    add_action( 'site-reviews/review/created', function( $review, $request ) {
        // You can use the glsr_log() function to debug the $review 
        // and $request objects. The values will show up in the 
        // plugin Console on the Tools page. For example:
        glsr_log( $review );
        glsr_log( $request );
    }, 10, 2 );
    • This reply was modified 6 years, 2 months ago by Gemini Labs.
    Thread Starter novusstd

    (@novusstd)

    Thanks a lot

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Email when review was approved’ is closed to new replies.