I used to be given an project that follows a situation for basketball gamers. It comprises a customized publish kind ‘participant’ that exist with a meta discipline name ‘player_external_id’ assuming all gamers has a really distinctive ID aside from WordPress ID.
All gamers can have a web page on the third social gathering web site with the next construction
"http://example.com/channel/{player_external_id}"
A brand new meta discipline ‘player_tv_url’ was added to the ‘participant’ customized publish and all new gamers drafted for the upcoming season have the correct worth set.
They wanted to replace any lacking ‘player_tv_url’ publish metadata and I used to be requested to write down a code that might accomplish that.
Right here is the code I submitted:
perform check_post_update_meta ($post_id, $key, $worth) {
$response = get_post_meta($post_id, $key, true);
if ($response == $worth) {
return true;
} else {
$response = update_post_meta($post_id, $key, $worth);
}
}
How would I set off the execution of the code?
update_post_meta($post_id, 'player_tv_url', $worth);
I acquired suggestions saying there have been elements lacking in my code. I believed I used to be heading in the fitting path. I do not know what went improper? I want to know what is precisely lacking in my code with a view to repair it.