Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you want to have the form processed on the remote server, you can remotely add the submission to WordPress via XMLRPC.</p> <p>An example as follows:</p> <pre><code>&lt;?php class XMLRPClientWordPress { var $XMLRPCURL = ""; var $UserName = ""; var $PassWord = ""; // constructor public function __construct($xmlrpcurl, $username, $password) { $this-&gt;XMLRPCURL = $xmlrpcurl; $this-&gt;UserName = $username; $this-&gt;PassWord = $password; } function send_request($requestname, $params) { $request = xmlrpc_encode_request($requestname, $params); $ch = curl_init(); curl_setopt($ch, CURLOPT_POSTFIELDS, $request); curl_setopt($ch, CURLOPT_URL, $this-&gt;XMLRPCURL); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 1); $results = curl_exec($ch); curl_close($ch); return $results; } function create_post($title,$body,$category,$keywords='',$encoding='UTF-8') { $title = htmlentities($title,ENT_NOQUOTES,$encoding); $keywords = htmlentities($keywords,ENT_NOQUOTES,$encoding); $content = array( 'title'=&gt;$title, 'description'=&gt;$body, 'mt_allow_comments'=&gt;0, // 1 to allow comments 'mt_allow_pings'=&gt;0, // 1 to allow trackbacks 'post_type'=&gt;'post', 'mt_keywords'=&gt;$keywords, 'categories'=&gt;array($category) ); $params = array(0,$this-&gt;UserName,$this-&gt;PassWord,$content,true); return $this-&gt;send_request('metaWeblog.newPost',$params); } function create_page($title,$body,$encoding='UTF-8') { $title = htmlentities($title,ENT_NOQUOTES,$encoding); $content = array( 'title'=&gt;$title, 'description'=&gt;$body ); $params = array(0,$this-&gt;UserName,$this-&gt;PassWord,$content,true); return $this-&gt;send_request('wp.newPage',$params); } function display_authors() { $params = array(0,$this-&gt;UserName,$this-&gt;PassWord); return $this-&gt;send_request('wp.getAuthors',$params); } function sayHello() { $params = array(); return $this-&gt;send_request('demo.sayHello',$params); } } if(trim($_POST['subject'])=='' || trim($_POST['content'])==''){ die('All fields are required.'); } $xmlrpc = new XMLRPClientWordPress("http://yoursite.com/xmlrpc.php" , "username" , "password"); $xmlrpc-&gt;create_post( mb_convert_encoding(stripslashes($_POST['subject']), 'HTML-ENTITIES', 'UTF-8'), mb_convert_encoding(htmlentities(stripslashes($_POST['content']), ENT_COMPAT, 'UTF-8'), 'HTML-ENTITIES', 'UTF-8'), 1); echo 'Post successful!'; ?&gt; </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload