简体   繁体   中英

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. How do I post the username and password in 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. 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. 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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