WordPress.org

Ready to get started?Download WordPress

Forums

turning off multi site mode makes XMLRPC fail : you are not allowed to publish p (1 post)

  1. ben.IT
    Member
    Posted 1 year ago #

    Hi,I am encountering an annoying problem with XMLRPC in wordpress. The following error is thrown: "Sorry, you are not allowed to publish posts on this site" Here is a snippet to test :

    /*Credentials for XML-RPC server, plugin option*/
    define('XMLRPC_USER',get_option('xmlrpc_user')) ;
    define('XMLRPC_PWD',get_option('xmlrpc_pwd')) ;
    define('XMLRPC_URL',get_option('xmlrpc_url')) ;
    
    $client = new IXR_Client(XMLRPC_URL);
    
    $content = array(
            'title' => 'title',
            'description' => 'description', //$wp_post_to_sync->post_content
            'mt_allow_comments' => 0,  // 1 to allow comments
            'mt_allow_pings' => 0,  // 1 to allow trackbacks
            'post_type' => 'post',
    );
    
    $params = array(0,XMLRPC_USER,XMLRPC_PWD,$content,true); //true : publish, false, draft
    
    $client->query('metaWeblog.newPost',$params) ;
    
    var_dump($client->getErrorCode()) ;
    var_dump($client->getErrorMessage()) ;
    
    var_dump ($client->getResponse());

    The code works fine when the website is set in multisite mode but when I turn the website in single mode, it fails.

    /**
    define('WP_ALLOW_MULTISITE', true);
    // COMMENT MULTISITE SECTION
    define( 'MULTISITE', true);
    define( 'SUBDOMAIN_INSTALL', false );
    $base = '/';
    define( 'DOMAIN_CURRENT_SITE', 'mydomain.fr' );
    define( 'PATH_CURRENT_SITE', '/' );
    define( 'SITE_ID_CURRENT_SITE', 1 );
    define( 'BLOG_ID_CURRENT_SITE', 1 );
    */

    Does anybody can help me ?

    Thanks, ben

Topic Closed

This topic has been closed to new replies.

About this Topic