我将以下代码用于通过curl执行的外部php文件:
<?php
include ('wp-config.php'); //Not sure how to do it.
if (!empty($_POST['username']) && !empty($_POST['password'])) {
$username= $_POST['username'];
$password= $_POST['password'];
$url = 'http://www.example.com/RequestDetails?UserId='.$username.'&pass='.$password;
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$resultauth=curl_exec($ch);
curl_close($ch);
$result = file_get_contents($url);
/*----Working fine till now*/
if ($results == 'authenticated user'){
$auth_options = get_option( 'user_options' );
$auth_options['user'][$username] = array( 'verified'=>'pendingverified', 'timestamp'=> current_time( 'mysql' ) );
}
?>
$auth_options['user'][$username]
无效,我猜是因为此文件未链接到wordpress。
有人知道为什么会这样吗?我忘了包括什么吗?
答案 0 :(得分:1)
尝试包含wp-load.php
include ( 'wp-load.php' );