check for duplicate user meta data before updating

You can check duplicate user meta using sql query.in below code if duplicate record found of other users then it will display error message and not update value. add below code in active theme’s functions.php file. function save_cust_user_profile_fields( $user_id ) { if ( isset($_POST[‘social_number’]) ) { global $wpdb; $social_number = $_POST[‘social_number’]; # query to check … Read more

Adding a custom Shipping methods field to an order

Below is what I used in the end to solve my problem: add_action(‘woocommerce_init’, ‘shipping_instance_form_fields_filters’); function shipping_instance_form_fields_filters() { $shipping_methods = WC()->shipping->get_shipping_methods(); foreach($shipping_methods as $shipping_method) { add_filter(‘woocommerce_shipping_instance_form_fields_’ . $shipping_method->id, ‘shipping_instance_form_add_extra_fields’); } } function shipping_instance_form_add_extra_fields($settings) { $settings[‘route_number’] = [ ‘title’ => ‘Route Number’, ‘type’ => ‘text’, ‘placeholder’ => ‘1,2,3…’, ‘description’ => ‘Enter route number’ ]; return $settings; } … Read more

Category Search / Custom Post Type search on my website. Custom Post Types that are “page-like”?

You can limit a search to a particular post-type quite easily: https://www.wpbeginner.com/wp-tutorials/how-to-limit-search-results-for-specific-post-types-in-wordpress/ Or a nice simple way to limit a search to a particular category by adding a hidden field into the search form: https://www.wpexplorer.com/limit-wordpress-search/ In terms of post vs page for custom post types, you can find the differences on the documentation page for … Read more

Sanitize user input fields before wp_insert_post

If calling, sanitize_text_field(), it actually call an internal function _sanitize_text_fields() and add a filter for override. So First look at _sanitize_text_fields(), which actually do Checks for invalid UTF-8, Converts single < characters to entities Strips all tags <——— including wp_strip_all_tags() here Removes line breaks, tabs, and extra whitespace Strips octets That’s mean if calling sanitize_text_field(), … Read more