Remove users from WP-JSON

add_filter(‘rest_endpoints’, function( $endpoints ) { if ( isset( $endpoints[‘/wp/v2/users’] ) ) { unset( $endpoints[‘/wp/v2/users’] ); } if ( isset( $endpoints[‘/wp/v2/users/(?P[\d]+)’] ) ) { unset( $endpoints[‘/wp/v2/users/(?P[\d]+)’] ); } return $endpoints; });Continue reading

Add the page slug body class

function wpcode_snippet_add_slug_body_class( $classes ) { global $post; if ( isset( $post ) ) { $classes[] = $post->post_type . ‘-‘ . $post->post_name; } return $classes; } add_filter( ‘body_class’, ‘wpcode_snippet_add_slug_body_class’ );Continue reading

webhooks

add_filter( ‘wpforms_webhooks_process_fill_http_body_params_value’, function ( $filled_params, $params, $process ) { foreach ( $filled_params as $key => $param ) { if ( $key == “booking_date” ) { $filled_params[ $key ] = $param[‘value’]; } elseif ( $key == “start_time” ) { $filled_params[ $key…Continue reading

Automatic CSS/JavaScript Cache Busting

/** * Replace the `ver` query arg with the file’s last modified timestamp * * @param string $src URL to a file * @return string Modified URL to a file */ function filter_cache_busting_file_src( $src = ” ) { global $wp_scripts;…Continue reading

FG_Sales

if( function_exists(‘acf_add_local_field_group’) ): acf_add_local_field_group(array( ‘key’ => ‘group_2_sales’, ‘title’ => ‘Sales Profile’, ‘fields’ => array( array( ‘key’ => ‘field_2_sales_name’, ‘label’ => ‘Full Name’, ‘name’ => ‘sales_name’, ‘type’ => ‘text’, ‘instructions’ => ‘Enter the full name of the salesperson.’, ‘required’ => 1,…Continue reading

Masterstudy LMS – Woocomerce Create Account After Payment

add_action(‘woocommerce_order_status_completed’, ‘create_user_and_notify_on_order_completion_with_masterstudy’); function create_user_and_notify_on_order_completion_with_masterstudy($order_id) { $order = wc_get_order($order_id); $customer_email = $order->get_billing_email(); // Find user by email $user = get_user_by(’email’, $customer_email); if ($user) { // Existing user found, update ‘customer’ role if (!in_array(‘customer’, $user->roles)) { $user->add_role(‘customer’); } // Update order to…Continue reading

Tutor LMS – Woocommerce Create Account After Payment

add_action(‘woocommerce_order_status_completed’, ‘create_user_and_notify_on_order_completion’); function create_user_and_notify_on_order_completion($order_id) { $order = wc_get_order($order_id); $customer_email = $order->get_billing_email(); // Find user by email $user = get_user_by(’email’, $customer_email); if ($user) { // Existing user found, update ‘customer’ role if (!in_array(‘customer’, $user->roles)) { $user->add_role(‘customer’); } // Update order to…Continue reading

Exporting custom meta

function custom_woo_ce_extend_product_fields( $fields ) { $fields[] = array( ‘name’ => ‘my_custom_field’, ‘label’ => __( ‘My Custom Field’, ‘woo_ce’ ) ); return $fields; } add_filters( ‘woo_ce_product_fields’, ‘custom_woo_ce_extend_product_fields’ );Continue reading

Exporting custom meta

function woo_ce_extend_product_item( $product, $product_id ) { $product->my_custom_field = get_post_meta( $product_id, ‘_my_custom_field’, true ); return $product; } add_filter( ‘woo_ce_product_item’, ‘custom_woo_ce_extend_product_item’, 10, 2 );Continue reading

Editing Scheduled Export e-mail content

function custom_woo_ce_email_contents( $content = ” ) { // Change the below text so whatever you prefer $content = ‘Please find attached your export ready to review.’; // wpautop() changes double line-breaks in the text into HTML paragraphs $content = wpautop(…Continue reading