[英]Wordpress - Using functions outside Wordpress
我将以下代码用于通过 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。
有人知道为什么会这样吗? 我忘记包含一些东西了吗?
尝试包含 wp-load.php
include ( 'wp-load.php' );
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.