Make WordPress Core


Ignore:
Timestamp:
01/21/2019 01:33:50 AM (6 years ago)
Author:
pento
Message:

Comments: Show the "awaiting moderation" message when comment cookies are disabled.

The "Your comment is awaiting moderation." message relied upon the comment author cookie being set. However, since it's now possible to opt-out of that cookie, submitting a comment won't show the comment preview when the comment is placed in moderation.

To avoid this issue, we now include a hash in the redirect URL, allowing the site to identify that a preview of the moderated comment should be displayed.

Props imath, tomdxw, birgire, lakenh, azaozz, pento.
Fixes #43857.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-comments-post.php

    r43571 r44659  
    5757$location = empty( $_POST['redirect_to'] ) ? get_comment_link( $comment ) : $_POST['redirect_to'] . '#comment-' . $comment->comment_ID;
    5858
     59// Add specific query arguments to display the awaiting moderation message.
     60if ( 'unapproved' === wp_get_comment_status( $comment ) && ! empty( $comment->comment_author_email ) ) {
     61    $location = add_query_arg(
     62        array(
     63            'unapproved'      => $comment->comment_ID,
     64            'moderation-hash' => wp_hash( $comment->comment_date_gmt ),
     65        ),
     66        $location
     67    );
     68}
     69
    5970/**
    6071 * Filters the location URI to send the commenter after posting.
Note: See TracChangeset for help on using the changeset viewer.