perrybutler / WP-OAuth

A WordPress plugin that allows users to login or register by authenticating with an existing Google, Facebook, LinkedIn, Github, Reddit or Windows Live account via OAuth 2.0. Easily drops into new or existing sites, integrates with existing users.
GNU General Public License v2.0
97 stars 76 forks source link

Feature Request for the battle.net plugin. #14

Open stottsjr opened 9 years ago

stottsjr commented 9 years ago

When a new user is signing up using the battle.net credentials the default user name is set to "userX". Is it possible to populate the username with the battle tag id: https://us.api.battle.net/account/user/battletag?access_token= Which returns: {"battletag":"btagID"}

And then possibly populating "Display name publicly as" with the persons characters: https://us.api.battle.net/wow/user/characters?access_token=

If I knew more about WordPress I might be able to do this, but I have very limited knowledge of it at this time. I will try to plug away at it, but I thought I'd ask on here as well.

Hopefully I've described the request adequately.

Thanks!

perrybutler commented 9 years ago

Thanks for submitting this, the details are helpful and it's a good idea. As you know Battle.NET is not currently a supported provider, but it is one of the next I'd like to support with a future version of the plugin. Your idea should be a simple task to implement. I'll let you know when there's more progress on this provider.

perrybutler commented 9 years ago

Also see #5.

stottsjr commented 9 years ago

I have it where I am getting the user's battletag ID, but was curious if there's a string I can set so that wp-oauth will use this ID. Something in $oauth_identity maybe so it'll use that as the user id as opposed to "userX"?

Thanks!

perrybutler commented 9 years ago

Hi stottsjr, Battle.net was added in v0.4. Still no ability to customize the username or automatically fill the nickname though. This will be added in a future version for all providers. Users can still change their nickname via their profile page if that helps.

The username is handled in the register.php file. First we generate a unique username and attempt to create the user account. If that succeeds, we now have a user with a user_id in the WordPress database, so with that user_id we immediately rename the new user's username to userXXX where XXX is the user_id.

You said you have the battletag id? You would need to change the line ($username = "user" . $user_id;) in the register.php file to something like ($username = $battletag_id).

All this is outside the scope of what I am currently supporting for this plugin, so try it at your own risk and remember any changes you make to the core plugin will be overwritten when you update to the next version, which means you might want to avoid plugin updates or fork and rename the plugin. Feel free to plug away at this, but know that we will be adding this feature in a future version.