我需要在WP外部调用一个PHP脚本,我想利用WP的凭据,以便只有登录的用户才能访问此脚本。我曾尝试在外部PHP脚本中嵌入此代码,但无法使用(其中XXX是域名):
require(\'/var/www/vhosts/xxx.xxx.xxx/httpdocs/wordpress/wp-blog-header.php\');
if ( !is_user_logged_in () ) {
//the script exits if the user is not logged in
showAccessDenied($day, $month, $year, $area, isset($room) ? $room : "");
exit;
}
你有什么线索吗?非常感谢!!
SO网友:s_ha_dum
我会反过来做:
if ( !is_user_logged_in () ) {
//the script exits if the user is not logged in
require(\'/path/to/your/script.php\');
showAccessDenied($day, $month, $year, $area, isset($room) ? $room : "");
}
您可以通过多种方式将其输入到页面中。我没有足够的细节来提供一个适合您需要的示例。