This file contains 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
function wp_oauth_server_debug_backtrace() { | |
$friendly = array(); | |
$backtrace = debug_backtrace(); | |
foreach ( $backtrace as $file ) { | |
$friendly[] = array( | |
'file' => $file['file'], | |
'function' => $file['function'], | |
'line' => $file['line'] | |
); | |
} |
This file contains 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
do_action( 'wo_set_access_token', array( | |
'access_token' => $access_token, | |
'client_id' => $client_id, | |
'user_id' => $user_id | |
) ); |
This file contains 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 |
This file contains 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
/** | |
* This can be used in conjuction https://gist.github.com/justingreerbbi/768f1effcca69b4098c9d0f7731deba0 | |
* This code would go on the WP side. | |
*/ | |
add_action('clear_auth_cookie', 'wp_oaut_server_logout_user_rediect_to_client_rest_api_endpoint'); | |
function wp_oaut_server_logout_user_rediect_to_client_rest_api_endpoint(){ | |
wp_redirect('https://site.com/wp-json/wpoauthserver/v1/logout/'); | |
} |
This file contains 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_filter( 'template_redirect', 'auto_sso_init', 11 ); | |
function auto_sso_init() { | |
if ( ! is_user_logged_in() ) { | |
wp_safe_redirect( site_url( '?auth=sso' ) ); | |
exit; | |
} | |
} |
This file contains 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
function _proper_custom_login_redirect_intercept( $template ) { | |
if ( ! is_user_logged_in() ) { | |
wp_safe_redirect( site_url( '/member-login/' ) ); | |
exit; | |
} | |
return $template; | |
} |
This file contains 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
Plugin: Simple Single Sign On | |
Plugin File: /includes/callback.php | |
/* | |
* Action runs directly after a default user is created | |
*/ | |
do_action( 'wpoc_user_created', $user_info, 1 ); | |
/* | |
* Action runs directly before a user is logged in |
This file contains 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
/** | |
* CUSTOM LOGIN REDIRECT | |
* | |
* Redirect a user to a custom login page for authentication | |
*/ | |
add_action( 'wo_before_authorize_method', 'custom_login_redirect' ); | |
function custom_login_redirect() { | |
if ( ! is_user_logged_in() ) { | |
wp_redirect( site_url() . '/custom-login?redirect_to=' . urlencode( site_url() . $_SERVER['REQUEST_URI'] ) ); | |
exit; |
This file contains 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( 'login_init', 'secure_wp_admin' ); | |
function secure_wp_admin() { | |
/** | |
* Check if there is an redirect_url parameter during the login page. | |
* | |
* If the script has made it this far for WP OAuth Server, there will be redirect URL exposed for the login redirect | |
* required by WP OAuth Server. We can use this redirect as a flag to check for the path. If "oauth" is present, we | |
* should assume that the request is an oauth request and should not be redirected. | |
*/ |
This file contains 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
<?php | |
/** | |
* Modifies the order status for orders made with user wallet for WooCommerce | |
* Prioroty set HIGH for pro since plugin handles this filter and this is a bypass for statuses not yet supported | |
*/ | |
add_filter('wpuw_update_status', 'v3zzq_example_modify', 1); | |
function v3zzq_example_modify(){ | |
return 'processing'; | |
} |