0

我在 wordpress 网站的根目录中有一个文件夹。因此,wordpress 似乎被绕过了(预期的结果),但现在我想向谨慎的模块(位于 wordpress 根目录中的代码)添加功能,以检查我们是否登录到 wordpress……可以这能做到吗?

澄清文件夹结构

/wp-admin/
/wp-content/
index.php
... (all wordpress files)
/my-folder/    <~ I want to access via http://mysite.com/my-folder/
    index.php  <~ I want a line of php to check if user is logged in to wordpress or not
    style.css
4

1 回答 1

1

为此,您需要包含/要求位于所有 word press 文件中的文件“wp-blog-header.php”,并使用返回布尔值的 WorldPress 函数“is_user_logged_in()”,有关更多详细信息,请参阅 WorldPress PHP代码在这里

因此,您可以在文件 /my-folder/index.php 中使用类似这样的功能来检查用户是否登录到您的 WorldPress

function checkWPLogin(){
    require_once("../wp-blog-header.php");
    return is_user_logged_in();
}
于 2012-06-27T23:56:19.750 回答