Buik update custom field values from external API

I suggest using a WordPress cron job, in the form of a real server cron job (by default WordPress cronjobs are executed when a user visits the website). Setting up a cron job (the easy way): https://kinsta.com/knowledgebase/wordpress-cron-job/ Real cronjob via server crontab: https://easyengine.io/tutorials/wordpress/wp-cron-crontab/

If one meta key value is empty, try to get another meta key, and if both meta keys are empty show something else?

You can use if else: <div class=”video-embed” style=”margin-top: 0px; z-index:102; margin-bottom: 0px;”> <?php $url1 = get_post_meta( $post->ID , ‘video_play’ , true ) ?: get_post_meta( $post->ID , ‘video_stop’ , true ) ?: false; if( $url1 ): $search=”#(.*?)(?:href=”https://wordpress.stackexchange.com/questions/302040/https?://)?(?:www\.)?(?:youtu\.be/”youtube\.com(?:/embed/|/v/|/watch?.*?v=))([\w\-]{10,12}).*#x”; $replace=”http://www.youtube.com/embed/$2″; $url = preg_replace($search,$replace,$url1); ?> <iframe width=”560″ height=”315″ src=”<?php echo $url; ?>” frameborder=”0″ allow=”autoplay; encrypted-media” allowfullscreen></iframe> <?php else: echo … Read more

How to redirect to home page according to a specific page custom fields value and user name

After the headers have been sent (output has been written to the screen) you can not use wp_redirect() try placing your code in the header.php before any output and see if that works well enough. If not you will have to hook into ‘send_headers’, ‘template_redirect’, or ‘init’ and check the values and redirect before any … Read more

How can I check if a custom field was updated?

I think you forgot the priority of hook and number of arguments otherwise code is perfect. If you can update post meta for custom post type then you refer this. https://codex.wordpress.org/Plugin_API/Action_Reference/updated_(meta_type)_meta Try Like this: add_action( ‘updated_post_meta’, ‘bg_update’, 10, 4 ); For custom post type EX: abc <?php add_action( “updated_{$meta_type}_meta”, $function_name’, 10, 4 ); ?> <?php … Read more