Skip Navigation

[Resolved] Add new relationship item does not work as expected

This support ticket is created 5 years, 11 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

This topic contains 5 replies, has 2 voices.

Last updated by Monika Beck 5 years, 11 months ago.

Assisted by: Shane.

Author
Posts
#1160856

I am dynamically setting the title of a custom post when the post is added or saved. This works fine with the following code:
add_action('save_post', 'myplugin_save_postdata',30,2);
/* When the post is saved, saves our custom data */
function myplugin_save_postdata($post_id,$post) {
global $wpdb;
if($post->post_type == 'catalog-item')
{
$mydata1 = get_post_meta($post_id,'wpcf-part',true);
$mydata2 = get_post_meta($post_id,'wpcf-size',true);
$mydata3 = get_post_meta($post_id,'wpcf-name',true);
$mytitle = $mydata3 . " - " . $mydata1;
$where = array( 'ID' => $post_id );
$wpdb->update( $wpdb->posts, array( 'post_title' => $mytitle ), $where );
}
}

This works when I go to the custom post type and add or edit a post. This does not work when I add a post from a custom relationship field. For example I have a custom post type "product". Each product can have multiple "catalog Item"s. When I add a catalog item normally, the post title save just fine. When I add a catalog item on the product page using the relationship field, the title does not save. It only has a -. It's lik the wpcf-part and wpcf-name are missing when adding the catalog item from the relationship field on the product page.

Any help would be greatly appreciated.

Thank you@!
Monika

#1160886

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Escalated

#1160887

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

#1160896

Hi Shane,

I have tried the hook you have suggested, but the same problem persists. The title still does not save.

Thanks,
Monika

#1161568

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Monika,

I checked again with our 2nd tier supporters.

Could you try with Priority 20 on your hook and see if it helps ?

Thanks,
Shane

#1161777

Thank you for your help. Although, I could not make toolset_association_created hook work, I was able to create a work around by using WP's save_post hook on the products type.