Jump to content

OAuth 2 WordPress plugin


Recommended Posts

Basically you can map anything into WordPress from what Vatsim gives you:
The CID is used as unique WordPress username, then you have some 'metadata' which is firstname and lastname. Maybe you need some plugins to show Fullname/lastname instead of Username in Posts/Forum etc, but that's secondary.

Return Array:
Array (
[data] => Array ( [cid] => 859396
[personal] => Array ( [name_first] => Jamie [name_last] => Janssen [name_full] => Jamie Janssen [email] => [email protected]
[country] => Array ( [id] => NL [name] => Netherlands ) )
[vatsim] => Array ( [rating] => Array ( [id] => 2 [long] => Tower Trainee [short] => S1 )
[pilotrating] => Array ( [id] => 0 )
[division] => Array ( [id] => EUD [name] => Europe (except UK) )
[region] => Array ( [id] => EUR [name] => Europe )
[subdivision] => Array ( [id] => NETH [name] => Dutch ) )
[oauth] => Array ( [token_valid] => true ) ) )

I hid my email adres ūüėȬ†But this is what you get. We feed this into WP and use WP_roles to assign a specific role (permission) to a user. This can be done using the Wordpress functions. Actually quite easy, for example:¬†https://developer.wordpress.org/reference/functions/wp_create_user/¬†to create the user.

So in short:
- we have a separate member role plugin to assign roles to a specific user (vatsim member, dutchvacc member, ATC, etc)
- we assign the roles upon login by checking the Array above: is the user's devision NETH? -> we assign DV Member.

The rest is done via the normal WordPress backend: permissions according the assigned roles to specific parts of the site. Works like a charm!

Edit: try to stick to the WordPress database specs. We did not 'hack' extra fields into the wp_user database for example. This to keep everything according WP standards and this keeps WP (hopefully) future proof.

Edited by Jamie Janssen
  • Like 1

Jamie Janssen

ACCNL3 Webmaster

Dutch VACC

 
 
 
  webmaster@dutchvacc.nl
  https://www.dutchvacc.nl
1867669885_DVLogo.thumb.jpg.3f12623d8d3006d2e0ec97a8469dab4b.jpg
Link to post
Share on other sites
3 hours ago, Jamie Janssen said:

Basically you can map anything into WordPress from what Vatsim gives you:
The CID is used as unique WordPress username, then you have some 'metadata' which is firstname and lastname. Maybe you need some plugins to show Fullname/lastname instead of Username in Posts/Forum etc, but that's secondary.

Return Array:
Array (
[data] => Array ( [cid] => 859396
[personal] => Array ( [name_first] => Jamie [name_last] => Janssen [name_full] => Jamie Janssen [email] => [email protected]
[country] => Array ( [id] => NL [name] => Netherlands ) )
[vatsim] => Array ( [rating] => Array ( [id] => 2 [long] => Tower Trainee [short] => S1 )
[pilotrating] => Array ( [id] => 0 )
[division] => Array ( [id] => EUD [name] => Europe (except UK) )
[region] => Array ( [id] => EUR [name] => Europe )
[subdivision] => Array ( [id] => NETH [name] => Dutch ) )
[oauth] => Array ( [token_valid] => true ) ) )

I hid my email adres ūüėȬ†But this is what you get. We feed this into WP and use WP_roles to assign a specific role (permission) to a user. This can be done using the Wordpress functions. Actually quite easy, for example:¬†https://developer.wordpress.org/reference/functions/wp_create_user/¬†to create the user.

So in short:
- we have a separate member role plugin to assign roles to a specific user (vatsim member, dutchvacc member, ATC, etc)
- we assign the roles upon login by checking the Array above: is the user's devision NETH? -> we assign DV Member.

The rest is done via the normal WordPress backend: permissions according the assigned roles to specific parts of the site. Works like a charm!

Edit: try to stick to the WordPress database specs. We did not 'hack' extra fields into the wp_user database for example. This to keep everything according WP standards and this keeps WP (hopefully) future proof.

Thank you so much for the very detailed explanation!!

Link to post
Share on other sites
  • 2 months later...

Hi there,

 

We are looking to integrate VATSIM Connect with our ARTCC website. It's powered by WP 5.6.1, and right now we have to manually create accounts for new controllers (home or visiting). Jamie, can you please get in touch with me privately by email (tyler.rodick (at) zlcartcc (dot) com) with info on how to set up this plugin as well as download details? Thanks.

 

Tyler Rodick, VATUSA ZLC ARTCC Assistant Webmaster

Link to post
Share on other sites

Hi all!

I just found a few spare minutes to¬†drop the bomb here ūüôā

The (currently unofficial) WorPress Vatsim Connect Plugin brought to you by the Dutch VACC.
https://gitlab.com/jamiejanssen/wp-plugin-vatsim-connect-public

We customized it heavily to our Dutch VACC's needs, so I had to clean quite a bit of the code to make things work for all VACCs. The code is small and clean. I guess quite readable as well. Feel free to comment/change and alter to your needs. Any questions? Just ask!

I HIGHLY recommend you to try this on a test-site first!

P.s. I'm not a professional programmer, I'm an airline captain. ENJOY!

Edited by Jamie Janssen
  • Like 1
  • Thanks 1

Jamie Janssen

ACCNL3 Webmaster

Dutch VACC

 
 
 
  webmaster@dutchvacc.nl
  https://www.dutchvacc.nl
1867669885_DVLogo.thumb.jpg.3f12623d8d3006d2e0ec97a8469dab4b.jpg
Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...