Last active
April 10, 2019 16:27
-
-
Save Asikur22/cfe7f3b00640c261c204e32e01ba2fc0 to your computer and use it in GitHub Desktop.
Show Custom Message After Posting Comment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Show Custom Message After post Comment. | |
*/ | |
function ar_set_comment_cookies( $comment, $user ) { | |
setcookie( 'ta_comment_wait_approval', '1', 0, '/' ); | |
} | |
add_action( 'set_comment_cookies', 'ar_set_comment_cookies', 10, 2 ); | |
function ar_comment_sent_message() { | |
if ( isset( $_COOKIE['ta_comment_wait_approval'] ) && $_COOKIE['ta_comment_wait_approval'] === '1' ) { | |
setcookie( 'ta_comment_wait_approval', '0', 0, '/' ); | |
function ar_show_comment_mesg() { | |
echo "<p id='wait_approval'><strong>Your comment has been sent successfully & Waiting for Approval.</strong></p>"; | |
} | |
add_action( 'comment_form_before', 'ar_show_comment_mesg' ); | |
} | |
} | |
add_action( 'init', 'ar_comment_sent_message' ); | |
function ar_comment_post_redirect( $location, $comment ) { | |
$location = get_permalink( $comment->comment_post_ID ) . '#wait_approval'; | |
return $location; | |
} | |
add_filter( 'comment_post_redirect', 'ar_comment_post_redirect', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment