admin管理员组文章数量:1122832
have a WordPress store and I built it using the WooCommerce plugin. Today, I encountered an issue with my site that I need help resolving. The problem is as follows:
Imagine a scenario where a logged-in user adds a few products to their cart. Two days later, they return to my site but unknowingly log out. They then add another product to their cart, but suddenly realize that they are not logged in. They then proceed to log in to their account, but upon doing so, their new cart overwrites their previous cart. I found my issue, I wrote a plugin for login and register, and I understand this issue appeared for this plugin, I used the wp_set_current_user function for logged-in users please see this function and say where is my problem my code is:
add_action('wp_ajax_SubmitPass', 'SubmitPass');
add_action('wp_ajax_nopriv_SubmitPass', 'SubmitPass');
function SubmitPass()
{
global $wpdb;
$UserID = intval($_POST['UserID']);
$UserPass = htmlspecialchars($_POST['UserPass']);
$User = $wpdb->get_results("SELECT `user_pass` FROM `wp_users` WHERE `ID` = $UserID");
$UserPassHash = $User[0]->user_pass;
if (wp_check_password($UserPass, $UserPassHash, $UserID)) {
wp_set_current_user($UserID); // Set the current user detail
wp_set_auth_cookie($UserID); // Set auth details in cookie
if (get_user_meta($UserID, 'UserPhone', true) == '') {
echo 'GoToGivePhone';
} else {
echo 'OK';
}
} else {
echo 'incorrect';
}
die(0);
}
本文标签: plugin developmenthow to works woocommerce cart hash
版权声明:本文标题:plugin development - how to works woocommerce cart hash 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736309846a1934165.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论