Created
November 15, 2019 00:55
-
-
Save justingreerbbi/8587d270cab2328bcd45f717b11336f6 to your computer and use it in GitHub Desktop.
Check Before Authorizing a User in WordPress OAuth after using Authorization Code Grant Type.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_action( 'wo_authorization_code_authorize', 'before_authorization_test' ); | |
| function before_authorization_test( $user_id ) { | |
| $user_id = $user_id[0]; | |
| $authorized = true; | |
| // Do user check and authorize if allowed | |
| // Present error is the user is not authorized | |
| if ( $authorized == false ) { | |
| $response = new WPOAuth2\Response(); | |
| $response->setError( 400, 'unauthorized_user', 'Unauthorized User' ); | |
| $response->send(); | |
| exit; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment