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'; | |
} |
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( 'rest_api_init', function () { | |
register_rest_route( 'myplugin/v1', '/author/(?P<id>\d+)', array( | |
'methods' => 'GET', | |
'callback' => 'my_awesome_func', | |
'args' => array( | |
'id' => array( | |
'validate_callback' => 'is_numeric' | |
), | |
), | |
'permission_callback' => function () { |
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 wo_woocommerce_login_redirect_example( $redirect ) { | |
if ( ! empty( $_REQUEST['redirect_to'] ) ) { | |
wp_redirect( $_REQUEST['redirect_to'] ); | |
exit; | |
} | |
return $redirect; | |
} |
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
$pName = $params["name"]; | |
$pDescription = 'Wallet Deposit'; | |
$pPrice = $params["tc_price"]; | |
$post_title = 'Fund Deposit ' . rand( 1000, 9999 ) . ' - ' . floatval( $params["tc_price"] ) . ' Credits'; | |
$post = array( | |
'post_author' => $pName, // User ID | |
'post_content' => $pDescription, | |
'post_status' => "public", | |
'post_title' => $post_title, |
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( 'wo_get_access_token_expires_return', 'wo_modify_expires_token' ); | |
function wo_modify_expires_token( $expires ) { | |
return strtotime( '+99 years', $expires ); | |
} |
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( 'uwcs_dynamic_deposit_template', 'custom_form_override', 99 ); | |
function custom_form_override( $template ) { | |
$return = ' | |
<style> | |
#uwcs-pro-custom-template { | |
text-align: center; | |
background-color: #FFF; | |
border: 1px solid #ccc; | |
padding: 1.5em; |
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( 'wo_me_resource_return', '234kdfe2_extend_me' ); | |
function example_extend_me_method( $data ) { | |
// Add new information to the user data | |
$roles = get_userdata( $data['ID'] ); | |
$data['roles'] = $roles; | |
// Grab a custom user meta field | |
$customer_user_meta = get_user_meta( $data['ID'], '_inc_user_type', true ); | |
$data['inc_user_type'] = $customer_user_meta; |
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
/** | |
* Head to https://wp-oauth.com for more info on user authentication and custom login and out solutions | |
* for WordPress | |
*/ | |
add_action( 'rest_api_init', function () { | |
register_rest_route( 'wpoauthserver/v1', '/logout/', array( | |
'methods' => 'GET', | |
'callback' => 'wp_oauth_server_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_action('init', 'set_allow_origins_header'); | |
function set_allow_origins_header(){ | |
// You can change the origin domain by removing * and replacing it with a valid domain. | |
header( 'Access-Control-Allow-Origin: *' ); | |
} |