New answers tagged

1

This quite rare setup so it is hard to recommend one way or another. Having worked with comments before I would recommend to stick with WordPress API functions (wp_insert_comment() and so on) for manipulating them. While DB structure is indeed simple you don't account for all the hooks firing and other things that might be happening. For example once in ...


0

Unfortunately the hooks: manage_{$this->screen->id}_columns manage_{$this->screen->id}_sortable_columns manage_comments_custom_column are not available for the post-comments list table, constructed within the wp_ajax_get-comments call. That table consists only of two columns: author and comment. The data for author, avatar, email, url and IP ...


0

For comment approved, you can review this question Approve comment hook? For comment submitted, you can hook into the comment_post hook, like function show_message_function( $comment_ID, $comment_approved ) { if( 0 === $comment_approved ){ //function logic goes here } } add_action( 'comment_post', 'show_message_function', 10, 2 ); Code ...


0

I have tried this in the following way, you can try this .... put the following code in functions.php function hide_comment_form_function( $comment_ID, $comment_approved ){ $commentData = get_comment( $comment_ID ); $postTitle = get_the_title($commentData->comment_post_ID); $url = get_site_url() ."/" .$postTitle . "/?status=cmt_post"; header("Location:...


0

Wordpress adds hashtag to URL if comment was successfully submitted. The easiest way to hide comment form or display some info is to check if hash exists with Javascript. hash = window.location.hash; if(hash){ $('#commentform').hide(); }


0

The following example uses the comment_post hook to run a function immediately after a comment is posted. The function checks whether the comment is approved and, if so, executes the code specified. function show_message_function( $comment_ID, $comment_approved ) { if( 1 === $comment_approved ){ //function logic goes here }}add_action( 'comment_post', '...


0

You got this action comment_post which fires just after comment is inserted in database


0

Demo - Setup Here's a demo how we could control the display of comment fields and their order: Let's create a custom class: $mycf = new MyCommentFields; Then we define our extra fields: $myfields = []; $myfields['myaddress'] = sprintf( '<p class="comment-form-myaddress"> <label for="myaddress">%s <span class="required">*&...


3

I wonder if you mean this kind of approach: add_filter( 'init', function() { $u = wp_get_current_user(); if( $u->exists() && in_array( 'banned', $u->roles, true ) ) add_filter( 'comments_open', '__return_false' ); } ); where we check if the current user has the custom banned role. If that's the case then we force all ...


0

Add bellow code in your functions.php file. } add_filter('comment_form_default_fields','remove_comment_fields'); function remove_comment_fields($fields) { unset($fields['url']); return $fields; } add_filter('comment_form_default_fields','remove_comment_fields'); Refference url



Top 50 recent answers are included