In an attempt to automatically covert the performance time to seconds I created a custom field similar to your previous example and tried to use the below code to update the field but it does not seem to work
You're asking me to troubleshoot and debug custom code. I can show you how to set a custom field value using PHP, but beyond that custom code like this is outside the scope of support we provide here in the forums. Please refer to our support policy: https://toolset.com/toolset-support-policy/
If you want to debug your own custom code, I suggest you add error log statements like so:
function change_to_seconds( $post_id, $post ){
error_log('change_to_seconds');
if ( 'swimming-event-player' == $post->post_type ) {
error_log('swimming-event-player post type');
$timestring = get_post_meta( $post_id, 'wpcf-swimming-performance', true );
error_log('timestring: ' . $timestring);
...and so on, for each step of the code. Then you will be able to watch the server logs to determine why the code isn't working as you might expect. If you're not familiar with server logs, I can show you how to activate them temporarily. Go in your wp-config.php file and look for
define('WP_DEBUG', false);
Change it to:
define('WP_DEBUG', true);
Then add these lines, just after the WP_DEBUG line:
Okay, I understand. What I really want to ask is if there is any way I can automatically copy information from a field in an intermediary post to another field in the same intermediary post, similar to the way you showed me in copying from parent to child
Replace 12345 with the ID of the intermediary post, replace field-1 with the slug of the field you want to copy from, and replace field-2 with the slug of the field you want to copy to.
So the slug is swimming-event-player, not swimming-event-playe, right? Check the spelling of the slug please, because it is spelled differently in the URL you just provided.
Hello, apologies for the delay in response as I have been away for some days.
I created a many to many relationship to connect swimming and players with slug "swimming-event-player" and I also created an intermediary post type on that many to many relationship with slug "swimming-event-playe" see all of that here hidden link
Okay so as I was saying before, there is a typo in your code. The conditional for $rel_slug is wrong here:
if( $rel_slug == 'swimming-event-playe' ) {
The relationship slug is swimming-event-player, not swimming-event-playe as the code suggests. Also please note that you already have a function called automate_intermediary_gender_func in your custom code snippets. You'll need to rename this function to something other than automate_intermediary_gender_func to prevent a fatal error.