Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8619685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T06:23:59+00:00 2026-06-12T06:23:59+00:00

I’m trying to edit the error message that appears when you hit Add comment

  • 0

I’m trying to edit the error message that appears when you hit Add comment button (from Admin panel) without typing a comment.

Here’s wp_ajax_replyto_comment function (from wp-admin/includes/ajax-actions.php) that handles this error message.

function wp_ajax_replyto_comment( $action ) {
    global $wp_list_table, $wpdb;
    if ( empty( $action ) )
        $action = 'replyto-comment';

    check_ajax_referer( $action, '_ajax_nonce-replyto-comment' );

    set_current_screen( 'edit-comments' );

    $comment_post_ID = (int) $_POST['comment_post_ID'];
    if ( !current_user_can( 'edit_post', $comment_post_ID ) )
        wp_die( -1 );

    $status = $wpdb->get_var( $wpdb->prepare("SELECT post_status FROM $wpdb->posts WHERE ID = %d", $comment_post_ID) );

    if ( empty($status) )
        wp_die( 1 );
    elseif ( in_array($status, array('draft', 'pending', 'trash') ) )
        wp_die( __('ERROR: you are replying to a comment on a draft post.') );

    $user = wp_get_current_user();
    if ( $user->exists() ) {
        $user_ID = $user->ID;
        $comment_author       = $wpdb->escape($user->display_name);
        $comment_author_email = $wpdb->escape($user->user_email);
        $comment_author_url   = $wpdb->escape($user->user_url);
        $comment_content      = trim($_POST['content']);
        if ( current_user_can( 'unfiltered_html' ) ) {
            if ( wp_create_nonce( 'unfiltered-html-comment' ) != $_POST['_wp_unfiltered_html_comment'] ) {
                kses_remove_filters(); // start with a clean slate
                kses_init_filters(); // set up the filters
            }
        }
    } else {
        wp_die( __( 'Sorry, you must be logged in to reply to a comment.' ) );
    }

    if ( '' == $comment_content )
        wp_die( __( 'ERROR: please type a comment.' ) );

    $comment_parent = absint($_POST['comment_ID']);
    $comment_auto_approved = false;
    $commentdata = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_content', 'comment_type', 'comment_parent', 'user_ID');

    $comment_id = wp_new_comment( $commentdata );
    $comment = get_comment($comment_id);
    if ( ! $comment ) wp_die( 1 );

    $position = ( isset($_POST['position']) && (int) $_POST['position'] ) ? (int) $_POST['position'] : '-1';

    // automatically approve parent comment
    if ( !empty($_POST['approve_parent']) ) {
        $parent = get_comment( $comment_parent );

        if ( $parent && $parent->comment_approved === '0' && $parent->comment_post_ID == $comment_post_ID ) {
            if ( wp_set_comment_status( $parent->comment_ID, 'approve' ) )
                $comment_auto_approved = true;
        }
    }

    ob_start();
        if ( 'dashboard' == $_REQUEST['mode'] ) {
            require_once( ABSPATH . 'wp-admin/includes/dashboard.php' );
            _wp_dashboard_recent_comments_row( $comment );
        } else {
            if ( 'single' == $_REQUEST['mode'] ) {
                $wp_list_table = _get_list_table('WP_Post_Comments_List_Table');
            } else {
                $wp_list_table = _get_list_table('WP_Comments_List_Table');
            }
            $wp_list_table->single_row( $comment );
        }
        $comment_list_item = ob_get_contents();
    ob_end_clean();

    $response =  array(
        'what' => 'comment',
        'id' => $comment->comment_ID,
        'data' => $comment_list_item,
        'position' => $position
    );

    if ( $comment_auto_approved )
        $response['supplemental'] = array( 'parent_approved' => $parent->comment_ID );

    $x = new WP_Ajax_Response();
    $x->add( $response );
    $x->send();
}

I want to override this part only:

if ( '' == $comment_content )
        wp_die( __( 'ERROR: please type a comment.' ) );

Here is my code which is placed in my theme’s functions.php

function my_function_name() {
    if ( '' == $comment_content )
        wp_die( __( 'My custom message here' ) );
}
add_filter( 'wp_ajax_replyto_comment', 'my_function_name' );

Unfortunately, my code doesn’t work. Please help me! Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T06:24:00+00:00Added an answer on June 12, 2026 at 6:24 am

    There are certain functions that are “pluggable”, where you can override them, but that is not one of them.

    The only way to adjust the core functionality is with action hooks and filters, unless you want to just go in and edit the core directly (bad practice… upgrading the core will overwrite your changes).

    If you find a do_action('something'); in the core, you can hook in with add_action('something','my_function');.

    If you find an apply_filters('something', $value) in the core, you can filter that $value with add_filter('something', 'my_function');.

    By the way, in the above example, you would do:

    function my_function($value){
        // manipulate $value
        return $value;
    }
    

    Make sure to return something as the filtered value. Unfortunately I can’t seem to find anywhere to hook into for this :(.

    See http://codex.wordpress.org/Plugin_API for more info.

    If you MUST change that text, you could do it after the page loads with javascript.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a small JavaScript validation script that validates inputs based on Regex. I
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.