我有两个Wordpress插件,这两个插件的作者拒绝承认冲突/问题是他们的网站,但很明显,双方都可以很容易地解决问题。
我为一位插件作者提供了修补程序,它对插件没有任何负面影响,如果此人安装了第二个插件但是他们不会添加,则不会导致任何问题修复了他们的插件,即使它增加了与不同插件的兼容性。
我无法弄清楚如何修复第二个插件,但我知道需要做什么......
插件1中的/* check if the user is valid */
if ( true === wlm_admin_in_admin() || true === $special_bypass ) {
$validuser = username_exists( $data['username'] );
if ( ! $validuser ) {
$validuser = email_exists( $data['email'] );
$user_info = get_userdata( $validuser );
$data['username'] = $user_info->user_login;
}
$data['password'] = __( 'Already assigned', 'wishlist-member' );
} else {
$validuser = wp_login( $data['username'], $data['password'] );
}
if ( $validuser ) {
$user = $this->Get_UserData( 0, $data['username'] );
/* check for blacklist status */
$blacklist = $this->CheckBlackList( $user->user_email );
}
现在,如果找到行:
$validuser = wp_login( $data['username'], $data['password'] );
并将其替换为:
//$validuser = wp_login( $data['username'], $data['password'] );
$tmpvaliduser = username_exists( $data['username'] );
if ($tmpvaliduser)
$validuser = wp_login( $data['username'], $data['password'] );
if ( ! $validuser || !$tmpvaliduser) {
if((!$data['email']) && !(false === strrpos($data['username'], "@")) ) {
$validuser = email_exists( $data['username'] );
$user_info = get_userdata( $validuser );
$data['username'] = $user_info->user_login;
$validuser = wp_login( $data['username'], $data['password'] );
}
}
然后这解决了问题,因为它将$data['username']
变量更改为其实际用户名,这意味着插件1的其余部分将继续正确并将某些详细信息绑定到用户名(帐户),而不是由他们组成的用户名电子邮件(显然不作为用户名存在)
function email_login_authenticate( $user, $username, $password ) {
if ( is_a( $user, 'WP_User' ) )
return $user;
if ( !empty( $username ) ) {
$user = get_user_by( 'email', $username );
if ( isset( $user, $user->user_login, $user->user_status ) && 0 == (int) $user->user_status ) {
$username = $user->user_login;
}
$result = wp_authenticate_username_password( null, $username, $password );
if (is_a ( $result, 'WP_User' ) ) {
global $WishListMemberInstance;
$WishListMemberInstance->WPMAutoLogin($user->ID);
$_POST['log'] = $username;
$WishListMemberInstance->Login();
}
}
return wp_authenticate_username_password( null, $username, $password );
}
我并不是100%确定上面的snippit完全做了什么,但我理解它已经足够好了,我需要更改它以便返回正确的用户名 以某种方式以便$data['username']
替换为用户名而不是电子邮件(如果使用电子邮件)
答案 0 :(得分:1)
首先,我的wordpress版本
UPDATE mrbs_entry AS tab1
INNER JOIN (SELECT other_side.id, other_side.name, other_side.start_time
FROM mrbs_entry AS other_side
WHERE other_side.room_id = 3) as tab2
ON tab1.start_time = tab2.start_time
AND tab1.name = tab2.name
AND tab1.id != tab2.id
SET tab1.room_id = 1
WHERE tab1.room_id = 2
AND tab1.id IN(1,2,3,4)
我的centos6.4上的插件将安装在这个位置:
Name : wordpress Relocations: (not relocatable)
Version : 4.4 Vendor: Fedora Project
Release : 1.el6 Build Date: Wed 09 Dec 2015 11:40:49 AM EST
请注意,此功能(在我的系统上)并不总是返回用户,WP_Error也是
/usr/share/wordpress/wp-content/plugins
我发现的wp-email-login可能适合您:
http://plugins.svn.wordpress.org/wp-email-login/trunk/email-login.php
更清楚一点,来自插件2的片段应更改为:
/**
* Authenticate the user using the username and password.
*
* @since 2.8.0
*
* @param WP_User|WP_Error|null $user WP_User or WP_Error object from a previous callback. Default null.
* @param string $username Username for authentication.
* @param string $password Password for authentication.
* @return WP_User|WP_Error WP_User on success, WP_Error on failure.
*/
function wp_authenticate_username_password($user, $username, $password) {