TransWikia.com

Wordpress comments - how to check if comment still needs to be approved?

WordPress Development Asked on November 8, 2021

I created a comments.php template and which contains the following code:

<div class="amb-single-comments amb-container-parent override">
    <div class="amb-single-comments-container amb-container-child override">
        <div class="amb-single-comments-wrapper-centered override">
            
            

<?php if ( post_password_required() ) {
    return;
} ?>
        <?php if ( have_comments() ) : ?>
            
            <!-- Comments header -->
            <h3 class="amb-comments-title"><?php echo esc_html( get_theme_mod('amb_single_styleparts_comments_title', 'Comments') ); ?></h3>
            
            <!-- Comments list -->
            <ul class="amb-comments-list">
            <?php wp_list_comments( [
                    'reverse_top_level' => true, //Newest first
                    'callback' => 'amb_comments_output',
                    'per_page' => '200',
                    'max_depth' => 20
                ] ); ?> 
            </ul>
            
            
        <?php endif; ?>
        <?php if ( ! comments_open() && get_comments_number() && post_type_supports( get_post_type(), 'comments' ) ) : ?>
            <p class="no-comments">
<?php _e( 'Comments are closed.' ); ?>
            </p>
        <?php endif; ?>
            
        
        <!-- Comments reply form -->
        <div class="amb-comments-form">
<?php   $amb_comment_form_arguments = [
            'title_reply_before' => '<h3 id="reply-title" class="amb-comments-form-title comment-reply-title">',
            'title_reply_after'  => '</h3>',
            'title_reply'        => get_theme_mod('amb_single_styleparts_comments_formtitle', 'Leave a reply' ),
        ];
            
        comment_form($amb_comment_form_arguments); ?>
            
        </div>
            

        </div>
    </div>
</div>

The callback function for the wp_list_comments is only relevant for each individual comment, so I didn’t include it here.

The comment form all works as expected. However, I now have a problem with the moderation. When a user adds a comment, it is not visible directly. (I didn’t research if users can change this behaviour, but I guess they can.)

I want to add some text to show to the user after posting the comment that the comment first needs to be moderated. How can I show this? Or, better: how do I check after a comment is submitted, if this comment first needs to be moderated (or not)?

What is the best way to incorporate this message in a comments.php template?

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP