Skip to content

Instantly share code, notes, and snippets.

View wbaxterh's full-sized avatar

Wes Huber wbaxterh

View GitHub Profile
@wbaxterh
wbaxterh / functions.php
Created November 2, 2022 15:14
Pass Woocommerce Product Data to Contact Form 7
// add the action
add_action( 'woocommerce_product_meta_end', 'action_woocommerce_after_add_to_cart_form');
// define the woocommerce_after_add_to_cart_form callback
function action_woocommerce_after_add_to_cart_form( ) {
global $product;
$productId = $product->get_id();
$productName = $product->get_name();
// make action magic happen here...
echo '</div></div><div id="beforeContact" class="container w-100 p-2" style="clear: both;"></div>';
@wbaxterh
wbaxterh / gist:8da62e5832b3884e003994011f4164dd
Created October 21, 2022 12:13
ReactJS with Wordpress API
const getTimezone = async () => {
let get_url = "https://your-domain/wp-json/wp/v2/users/" + userId;
axios.get(get_url, {
headers: {
'X-WP-Nonce': nonce,
}
}).then((response) => {
console.log(response.data.timezone);
})
}
//Add a timezone field to user profile - Wes Huber 10/2022
add_action( 'rest_api_init', 'adding_user_meta_rest' );
function adding_user_meta_rest() {
register_rest_field( 'user',
'timezone',
array(
'get_callback' => 'user_meta_callback',
'update_callback' => 'timezone_update',
'schema' => null,