Title: wp_xmlrpc_server::wp_editComment
Published: April 25, 2014
Last modified: August 20, 2026

---

# wp_xmlrpc_server::wp_editComment( array $args ): true|󠀁[IXR_Error](https://developer.wordpress.org/reference/classes/ixr_error/)󠁿

## In this article

 * [Description](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#description)
 * [Parameters](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#wp--skip-link--target)

Edits a comment.

## 󠀁[Description](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#description)󠁿

Besides the common blog_id (unused), username, and password arguments, it takes 
a comment_id integer and a content_struct array as the last argument.

The allowed keys in the content_struct array are:

 * ‘author’
 * ‘author_url’
 * ‘author_email’
 * ‘content’
 * ‘date_created_gmt’
 * ‘status’. Common statuses are ‘approve’, ‘hold’, ‘spam’. See [get_comment_statuses()](https://developer.wordpress.org/reference/functions/get_comment_statuses/)
   for more details.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#parameters)󠁿

 `$args`arrayrequired

Method arguments. Note: arguments must be ordered as documented.

 * `0` int
 * Blog ID (unused).
 * `1` string
 * Username.
 * `2` string
 * Password.
 * `3` int
 * Comment ID.
 * `4` array
 * Content structure.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#return)󠁿

 true|[IXR_Error](https://developer.wordpress.org/reference/classes/ixr_error/) 
True, on success.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#source)󠁿

    ```php
    public function wp_editComment( $args ) {
    	$this->escape( $args );

    	$username       = $args[1];
    	$password       = $args[2];
    	$comment_id     = (int) $args[3];
    	$content_struct = $args[4];

    	$user = $this->login( $username, $password );
    	if ( ! $user ) {
    		return $this->error;
    	}

    	if ( ! get_comment( $comment_id ) ) {
    		return new IXR_Error( 404, __( 'Invalid comment ID.' ) );
    	}

    	if ( ! current_user_can( 'edit_comment', $comment_id ) ) {
    		return new IXR_Error( 403, __( 'Sorry, you are not allowed to moderate or edit this comment.' ) );
    	}

    	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    	do_action( 'xmlrpc_call', 'wp.editComment', $args, $this );
    	$comment = array(
    		'comment_ID' => $comment_id,
    	);

    	if ( isset( $content_struct['status'] ) ) {
    		$statuses = get_comment_statuses();
    		$statuses = array_keys( $statuses );

    		if ( ! in_array( $content_struct['status'], $statuses, true ) ) {
    			return new IXR_Error( 401, __( 'Invalid comment status.' ) );
    		}

    		$comment['comment_approved'] = $content_struct['status'];
    	}

    	// Do some timestamp voodoo.
    	if ( ! empty( $content_struct['date_created_gmt'] ) ) {
    		// We know this is supposed to be GMT, so we're going to slap that Z on there by force.
    		$date_created = rtrim( $content_struct['date_created_gmt']->getIso(), 'Z' ) . 'Z';

    		$comment['comment_date']     = get_date_from_gmt( $date_created );
    		$comment['comment_date_gmt'] = iso8601_to_datetime( $date_created, 'gmt' );
    	}

    	if ( isset( $content_struct['content'] ) ) {
    		$comment['comment_content'] = $content_struct['content'];
    	}

    	if ( isset( $content_struct['author'] ) ) {
    		$comment['comment_author'] = $content_struct['author'];
    	}

    	if ( isset( $content_struct['author_url'] ) ) {
    		$comment['comment_author_url'] = $content_struct['author_url'];
    	}

    	if ( isset( $content_struct['author_email'] ) ) {
    		$comment['comment_author_email'] = $content_struct['author_email'];
    	}

    	$result = wp_update_comment( $comment, true );
    	if ( is_wp_error( $result ) ) {
    		return new IXR_Error( 500, $result->get_error_message() );
    	}

    	if ( ! $result ) {
    		return new IXR_Error( 500, __( 'Sorry, the comment could not be updated.' ) );
    	}

    	/**
    	 * Fires after a comment has been successfully updated via XML-RPC.
    	 *
    	 * @since 3.4.0
    	 *
    	 * @param int   $comment_id ID of the updated comment.
    	 * @param array $args       An array of arguments to update the comment.
    	 */
    	do_action( 'xmlrpc_call_success_wp_editComment', $comment_id, $args ); // phpcs:ignore WordPress.NamingConventions.ValidHookName.NotLowercase

    	return true;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/class-wp-xmlrpc-server.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.1/src/wp-includes/class-wp-xmlrpc-server.php#L3816)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.1/src/wp-includes/class-wp-xmlrpc-server.php#L3816-L3899)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#hooks)󠁿

 [do_action( ‘xmlrpc_call’, string $name, array|string $args, wp_xmlrpc_server $server )](https://developer.wordpress.org/reference/hooks/xmlrpc_call/)

Fires after the XML-RPC user has been authenticated but before the rest of the method
logic begins.

 [do_action( ‘xmlrpc_call_success_wp_editComment’, int $comment_id, array $args )](https://developer.wordpress.org/reference/hooks/xmlrpc_call_success_wp_editcomment/)

Fires after a comment has been successfully updated via XML-RPC.

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#related)󠁿

| Uses | Description | 
| [get_date_from_gmt()](https://developer.wordpress.org/reference/functions/get_date_from_gmt/)`wp-includes/formatting.php` |

Given a date in UTC or GMT timezone, returns that date in the timezone of the site.

  | 
| [iso8601_to_datetime()](https://developer.wordpress.org/reference/functions/iso8601_to_datetime/)`wp-includes/formatting.php` |

Given an ISO 8601 (Ymd\TH:i:sO) date, returns a MySQL DateTime (Y-m-d H:i:s) format used by post_date[_gmt].

  | 
| [wp_update_comment()](https://developer.wordpress.org/reference/functions/wp_update_comment/)`wp-includes/comment.php` |

Updates an existing comment in the database.

  | 
| [get_comment_statuses()](https://developer.wordpress.org/reference/functions/get_comment_statuses/)`wp-includes/comment.php` |

Retrieves all of the WordPress supported comment statuses.

  | 
| [IXR_Error::__construct()](https://developer.wordpress.org/reference/classes/ixr_error/__construct/)`wp-includes/IXR/class-IXR-error.php` |

PHP5 constructor.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [__()](https://developer.wordpress.org/reference/functions/__/)`wp-includes/l10n.php` |

Retrieves the translation of $text.

  | 
| [do_action()](https://developer.wordpress.org/reference/functions/do_action/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to an action hook.

  | 
| [wp_xmlrpc_server::escape()](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/escape/)`wp-includes/class-wp-xmlrpc-server.php` |

Escapes string or array of strings for database.

  | 
| [wp_xmlrpc_server::login()](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/login/)`wp-includes/class-wp-xmlrpc-server.php` |

Logs user in.

  | 
| [get_comment()](https://developer.wordpress.org/reference/functions/get_comment/)`wp-includes/comment.php` |

Retrieves comment data given a comment ID or comment object.

  | 
| [is_wp_error()](https://developer.wordpress.org/reference/functions/is_wp_error/)`wp-includes/load.php` |

Checks whether the given variable is a WordPress Error.

  |

[Show 8 more](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/wp_editcomment/?output_format=md#changelog)󠁿

| Version | Description | 
| [2.7.0](https://developer.wordpress.org/reference/since/2.7.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_xmlrpc_server%2Fwp_editcomment%2F)
before being able to contribute a note or feedback.