php - 有人可以帮我解决这个问题吗?未捕获的错误:调用成员函数存在()
问题描述
我在我的网站上安装了 wordpress,我有一个插件,可以从 xenforo 获取用户名并导入它们。一些用户已经在 wordpress 上创建,现在这些用户在尝试登录时会收到此错误。有人可以帮助避免这种情况的代码吗?
Uncaught Error: Call to a member function exists() on string in /home/xxx/public_html/blog/wp-
includes/user.php on line 1365
clean_user_cache()
wp-includes/pluggable.php:2532
wp_set_password()
wp-content/plugins/xpress-forum-user-bridge/src/Filter/Authenticate.php:107
createUser()
wp-content/plugins/xpress-forum-user-bridge/src/Filter/Authenticate.php:94
authenticate()
wp-includes/class-wp-hook.php:288
apply_filters()
wp-includes/plugin.php:206
apply_filters()
wp-includes/pluggable.php:539
wp_authenticate()
wp-includes/user.php:95
wp_signon()
wp-login.php:1187
这是插件中的 Authenticate.php
public static function authenticate($user, $login, $password)
{
if (get_option('xpress_lite_auth_with_xf', false) && $login && $password) {
if ($user instanceof \WP_User) {
return $user;
}
$apiClient = self::apiClient();
if (!$apiClient) {
return $user;
}
try {
$xfUser = $apiClient->xf->auth->auth($login, $password);
} catch (AbstractRequestException $e) {
return $user;
} catch (XFApiException $e) {
return $user;
}
if ($xfUser) {
return self::createUser($xfUser, $password, $login);
}
}
return $user;
}
protected static function createUser($xfUser, $password, $login)
{
if ($xfUser->email) {
$emailUser = get_user_by('email', $xfUser->email);
if ($emailUser) {
wp_set_password($emailUser->ID, $password);
return $emailUser;
}
}
$nameUser = get_user_by('login', $xfUser->username);
if ($nameUser) {
$newName = $xfUser->email;
} else {
$newName = $xfUser->username;
}
$userId = wp_create_user($newName, $password, $xfUser->email);
return get_user_by('ID', $userId);
}
}
解决方案
将 FS_METHOD 添加到 wp-config.php 解决了这些问题。
// worked
define('FS_METHOD','direct');
起初我走的是 FTP 用户的路线,但由于插件不断请求绝对路径,因此锁定用户对子目录的访问权限再次中断。在我的情况下,即使在配置中添加路径也无济于事。
// updating paths did not help
define( 'FTP_BASE', '/path/to/wordpress/' );
define( 'FTP_CONTENT_DIR', '/path/to/wordpress/wp-content/' );
define( 'FTP_PLUGIN_DIR ', '/path/to/wordpress/wp-content/plugins/' );
define( 'FTP_USER', 'username' );
define( 'FTP_PASS', 'password' );
define( 'FTP_HOST', 'ftp.example.org' );
define( 'FTP_SSL', false );