简体   繁体   English

使用PHP在Wordpress中发布用户名和密码

[英]Post username and password in Wordpress with PHP

I am trying to integrate an external script with wordpress.. I need t create a way that when a member logins this external script, the user will be logged in Wordpress too. 我正在尝试将外部脚本与wordpress集成。我不需要创建一种方式,当成员登录此外部脚本时,用户也将登录到Wordpress中。 How do I post the username and password in Wordpress. 如何在Wordpress中发布用户名和密码。 Wordpress is installed in a subfolder of this external script, same database and obviouly same domain name.. The username and password used on the extrnal script are the same of the wordpress ones. Wordpress安装在该外部脚本的子文件夹中,该文件夹具有相同的数据库和非常相同的域名。外部脚本上使用的用户名和密码与wordpress相同。 I just need a way to login the user with one unique form for both.. Let me know! 我只需要一种使用两种形式的唯一表单登录用户的方法。 I do not have any code so far..I do not know where to start! 到目前为止我还没有任何代码..我不知道从哪里开始! Thank you!! 谢谢!!

Don't post username and password if its under same domain. 如果用户名和密码在同一域中,则不要发布。 Set the wordpress cookie instead. 改为设置wordpress cookie。 Some thing like this should get you started: 这样的事情应该可以帮助您入门:

require('wp-blog-header.php');
$user_login = 'username';
$user = get_userdatabylogin($user_login);
$user_id = $user->ID;
wp_set_current_user($user_id, $user_login);
wp_set_auth_cookie($user_id);
do_action('wp_login', $user_login);

You might want to read more on this: WordPress Auto-Login 您可能需要阅读以下内容: WordPress自动登录

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM