Title: wp_xmlrpc_server::mt_publishPost
Published: April 25, 2014
Last modified: May 20, 2026

---

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

## In this article

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

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

Sets a post’s publish status to ‘publish’.

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

 `$args`arrayrequired

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

 * `0` int
 * Post ID.
 * `1` string
 * Username.
 * `2` string
 * Password.

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

 int|[IXR_Error](https://developer.wordpress.org/reference/classes/ixr_error/)

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

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

    	$post_id  = (int) $args[0];
    	$username = $args[1];
    	$password = $args[2];

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

    	/** This action is documented in wp-includes/class-wp-xmlrpc-server.php */
    	do_action( 'xmlrpc_call', 'mt.publishPost', $args, $this );

    	$postdata = get_post( $post_id, ARRAY_A );
    	if ( ! $postdata ) {
    		return new IXR_Error( 404, __( 'Invalid post ID.' ) );
    	}

    	if ( ! current_user_can( 'publish_posts' ) || ! current_user_can( 'edit_post', $post_id ) ) {
    		return new IXR_Error( 401, __( 'Sorry, you are not allowed to publish this post.' ) );
    	}

    	$postdata['post_status'] = 'publish';

    	// Retain old categories.
    	$postdata['post_category'] = wp_get_post_categories( $post_id );
    	$this->escape( $postdata );

    	return wp_update_post( $postdata );
    }
    ```

[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.0/src/wp-includes/class-wp-xmlrpc-server.php#L6861)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-includes/class-wp-xmlrpc-server.php#L6861-L6892)

## 󠀁[Hooks](https://developer.wordpress.org/reference/classes/wp_xmlrpc_server/mt_publishpost/?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.

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

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

Retrieves the list of categories for a post.

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

Updates a post with new post data.

  | 
| [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.

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

Retrieves post data given a post ID or post object.

  | 
| [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.

  |

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

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

| Version | Description | 
| [1.5.0](https://developer.wordpress.org/reference/since/1.5.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%2Fmt_publishpost%2F)
before being able to contribute a note or feedback.