I have a site that has a Wordpress blog section. I would like to enable Single Sign On in the site so that on logging onto my site, the WP blog also logs on on simultaneously. I have two user tables. One for the site, other for the WP part. What I did was add a curl along with the function for logging on the site's blog section. Below is the code that I had used.
$username = $_POST['username']; $password = $_POST['password']; $url="http://www.crickees.svn.local/blog/"; $cookie="cookie.txt"; $postdata = "log=". $username ."&pwd=". $password ."&wp-submit=Log%20In&redirect_to=". $url ."wp-admin/&testcookie=1"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url . "wp-login.php"); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:184.108.40.206) Gecko/20070725 Firefox/220.127.116.11"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, $url . "wp-admin/"); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch);
Thing is that the
wp_signon() function is getting the values but it doesn't seem to be generating the required cookie. What changes are to be made to get the cookie generated.
I had tried another method where I hard coded the values into the wp_login.php page. Here I had set the values into the $creds array.
But that prevented logging out from the blog. So that plan didn't work out.
Some help would be nice. Thanks in advance.