admin管理员组文章数量:1323707
I have a wordpress + woocommerce site where the user can configure a product and create a custom one. The software that handle this configuration is on another server. So i need to send some data in POST and then, after the procedure on the external site is completed, retrieve the data and save the product as a woocommerce product. Actually i send the id of the user to the external site and retrieve it in post (the external site pass back the value that i've sent without changes).
This is the scenario: 1 - page1.php on the wordpress site --> form that send post data to external url. The user is already logged on woocommerce. The form is like this:
<form action="external site url.aspx" method="post" enctype="multipart/form-data">
<input type="hidden" name="CC" value="userID"> // this value is the wordpress user ID and is passed on external site
... other form fields
<button type="submit">Submit</button>
</form>
2 - The user is redirected to external site and do some stuff, after that the external site send post data and redirect on wordpress site
3 - page2.php on the wordpress site --> receive post data. The code that read the post data is like this:
if($_POST && $_POST['DO'] == 'save') {
$userID = $_POST['CC'];
wp_set_current_user($userID);
//take the other post parameters and do stuff...
}
In particular $POST['CC'] is the id of the user. The problem is that the user when is redirected on page2.php is not logged anymore on woocommerce. So i've used wp_set_current_user since i have the id of the user in post. I hope that now it's more clear.
Is it correct?
本文标签: serverCorrect user sessioncookie handling with external site connection in wordpress
版权声明:本文标题:server - Correct user sessioncookie handling with external site connection in wordpress 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742129607a2422098.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论