Want to help? STEAM login improvement
-
Hi All, been trying to improve the steam provider login. We had a need to pull a bit more info eg the steamID3, steamID64 etc for one of our sites.. and write this into wp_usermeta table.
We used https://steamidconverter.com/ to be able to get the info from steam, and then “scraped” what we needed – all working so far, but would like to ask anyone who wants to collaborate to improve the steam provider part of the plugin to please get involved.
The code below – was written as a function – but for tests i just placed in my themes footer area , juts before the
wp_footer();
part … because we are using buddypress as well, we are using the buddypress user id…What we are having hassles with is that we require the user to supply a valid email address, which we switched the check on in the bouncer area… but despite a user registering first time all good, on trying to login again, it keeps asking him for username / passwword saying user / email already exists….
I see that in wp_users the email the user entered on his first registration DOES get written to the table, but in wp_wslusersprofiles the email field is not being saved…. looking into the table i see that facbeook or linked providers saves the users email address no problem…
What is needed is that after the steam auth, it returns the screen that asks for a username and email address to be provided, what needs to happen is that that email address is SAVED to the wp_wslusersprofiles table as well so that when he logs in again, it can “marry” or match the existing user. Any IDEAS? or suggestions
Hope you guys get involved
<?php // ------ Greg - Get Steam ID - Trim to Usermeta ************************* global $wpdb, $bp; $uid = bp_loggedin_user_id(); $customURL = ''; $key = 'Steam'; $customURL = get_user_meta($uid, $key, true); //echo $customURL; if ($customURL) { $customURL = str_replace("https://steamcommunity.com/openid/id/", "", $customURL); $html = file_get_contents('https://steamidconverter.com/'.$customURL); $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); $elements = $xpath->query('//h2[@id=\'steamID\']'); $steam_id = null; foreach($elements as $element) { $steam_id = $element->nodeValue; } $elements = $xpath->query('//h2[@id=\'steamID3\']'); $steam_id_3 = null; foreach($elements as $element) { $steam_id_3 = $element->nodeValue; } $elements = $xpath->query('//h2[@id=\'name\']'); $username = null; foreach($elements as $element) { $username = $element->nodeValue; } $steam_info['steam_id'] = $steam_id; $steam_info['steam_id_3'] = $steam_id_3; $steam_info['username'] = $username; update_user_meta( $uid, 'steam_username', $username ); update_user_meta( $uid, 'steam_id_3', $steam_id_3 ); update_user_meta( $uid, 'steam_id_1', $steam_id ); update_user_meta( $uid, 'steam_id', $customURL ); //return $steam_info; } wp_footer(); ?>
- The topic ‘Want to help? STEAM login improvement’ is closed to new replies.