WP_Http::post() WordPress Method

The post() method is used to send data to a specified URL using the POST method. This is useful for sending data to a script or website that does not support the GET method.

WP_Http::post( string $url, string|array $args = array() ) #

Uses the POST HTTP method.


Description

Used for sending data that is expected to be in the body.


Top ↑

Parameters

$url

(string)(Required)The request URL.

$args

(string|array)(Optional) Override the defaults.

Default value: array()


Top ↑

Return

(array|WP_Error) Array containing 'headers', 'body', 'response', 'cookies', 'filename'. A WP_Error instance upon error.


Top ↑

Source

File: wp-includes/class-wp-http.php

	public function post( $url, $args = array() ) {
		$defaults    = array( 'method' => 'POST' );
		$parsed_args = wp_parse_args( $args, $defaults );
		return $this->request( $url, $parsed_args );
	}


Top ↑

Changelog

Changelog
VersionDescription
2.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.