Problem: I would like to use the title of a parent post to set a custom field value using a cred_save_data hook, but I'm not sure how to access the parent post.
Solution: It depends on when this Form was created and whether or not this post relationship has been migrated into the new Post Relationships system. In the old system, you could access the parent post ID in the $_POST superglobal as _wpcf_belongs_concours_id, then get the title using get_the_title:
$meta_value = isset($_POST['_wpcf_belongs_concours_id']) ? get_the_title($_POST['_wpcf_belongs_concours_id']) : '';
In the new system, you can access the parent post using the updated relationship slug syntax. It looks like @relationship-slug_parent, but depends on your post relationship slug:
$meta_value = isset($_POST['@relationship-slug_parent']) ? get_the_title($_POST['@relationship-slug_parent']) : '';
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.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
Este tema contiene 2 respuestas, tiene 2 mensajes.
Última actualización por hace 6 años.
Asistido por: Christian Cox.