mardi 16 février 2016

Call to undefined function is_user_logged_in() wordpress

Bonjour ! j'ai essayer plusieurs fois d’exécuter une code php situé dans un plug-in wordpress width curl login and it always returns me the following message: "You do not have permission to access this page." the account by which I connect is an administrator account. thank you in advance

function curl_execute($login_user, $login_pass, $login_url, $visit_url, $http_agent, $cookie_file)
{

    if (!function_exists('curl_init') || !function_exists('curl_exec')) {
        return '{"error":"cUrl is not vailable in you PHP server."}';
    }

    // Preparing postdata for wordpress login
    $data = "log=" . $login_user . "&pwd=" . $login_pass . "&wp-submit=Log%20In&redirect_to=" . $visit_url;

    // Intialize cURL
    $ch = curl_init();

    // Url to use
    curl_setopt($ch, CURLOPT_URL, $login_url);

    // Set the cookies for the login in a cookie file.
    curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);

    // Set SSL to false
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

    // User agent
    curl_setopt($ch, CURLOPT_USERAGENT, $http_agent);

    // Maximum time cURL will wait for get response. in seconds
    curl_setopt($ch, CURLOPT_TIMEOUT, 60);

    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);

    // Return or echo the execution
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    // Set Http referer.
    curl_setopt($ch, CURLOPT_REFERER, $login_url);

    // Post fields to the login url
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_POST, 1);

    //curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-type: application/json'));
    // Save the return in a variable
    $content = curl_exec($ch);

    // Close the cURL.
    curl_close($ch);

    // You can echo or return the page data here.
    return $content;
}

//call

$this->curl_execute($sync_login_user, $sync_login_pass, $sync_login_url, $sync_visit_url, $http_agent, $cookie_file);



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire