I'm trying to authenticate users from my system database into wordpress database. Both databases has the users records, since my registration form in https://domain.tld/office/register records users in both databases. I'm using woocommerce api to accomplish that, but this API has no mention how to log users in.
My login form is here: https://domain.tld/office/login (use WP login form is not an option in my case)
This is what I had already tried in my login processing and didn't work
require '/var/www/store/wp-includes/user.php'; $credentials = array(); $credentials['user_login'] = $_POST['username']; $credentials['user_password'] = $_POST['password']; $credentials['remember'] = true; $autologin_user = wp_signon( $credentials, is_ssl() );
$url_wp = 'https://domain.tld/store/'; //$postdata = "log=" . $username . "&pwd=" . $password . "&wp-submit=Log%20In&redirect_to=" . $url_wp . "wp-admin/&testcookie=1"; $postdata = "log=" . $username . "&pwd=" . $password . "&wp-submit=Log%20In&redirect_to=" . $url_wp; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url_wp . "wp-login.php"); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 0); curl_setopt ($ch, CURLOPT_REFERER, $url_wp . "wp-login.php"); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch);
I'm also using the plugin 'jwt-authentication-for-wp-rest-api', here is the code to get the token (it works just as expected) but again no clue where to send the request with this cookie.
The basic idea behind this, my users need a shop to purchase items and the current "shop" is not an full e-commerce application. I'm not looking into plugin development or anything like that, just need my users to be logged with woocommerce store when they pass through their login in the office.
I have no more ideas how to accomplish that, it seems to be a very simple task but I'm failing to see the big picture.