允许登录用户执行外部PHP脚本

时间:2015-06-15 作者:user1401141

我需要在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;
} 
你有什么线索吗?非常感谢!!

1 个回复
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 : "");
}
您可以通过多种方式将其输入到页面中。我没有足够的细节来提供一个适合您需要的示例。

结束

相关推荐

Nginx-与URL中的.php进行的固定链接不起作用

我正在将一个站点从Apache服务器移动到nginx服务器。很多页面都有一个。permalink末尾的php扩展。尝试查看这些页面会导致找不到nginx 404。然而,这些页面在Apache上运行良好。以下是站点的服务器块配置:# Vhost Config: example.com server { root /var/www/vhosts/sites/www.example.com/web; index index.php index.html ind