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

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

Access ACF fields within custom preview function?

As documented, the preview_post_link passes the post object as the second parameter. You can use this to get any fields that you might want: add_filter( ‘preview_post_link’, function( $preview_link, $post ) { $custom_field = get_field( ‘custom_field_name’, $post ); return $preview_link; }, 10, 2 // MUST be 2 to get the $post parameter. );

Function that replaces the image in the absence of the post meta

found the solution: $poster_path = get_post_meta($post->ID, “poster_path”, $single = true); if( $poster_path == “” ){ echo ‘<img width=”53″ height=”80″ src=”https://via.placeholder.com/370×556?text=No+Poster&000.jpg” />’; } else { echo ‘<img width=”53″ height=”80″ src=”https://image.tmdb.org/t/p/w370_and_h556_bestv2′.$poster_path.'” />’; }