Problem: I am using the wpv-current-user shortcode to display the current User's display_name in a CRED form success message, but I would like to show their first and last name instead.
Solution: Remove the wpv-current-user shortcode and use the Fields and Views button to insert the correct information instead.
Problem: I am using cred_save_data to perform some actions after form submission, but the update_post_meta calls do not seem to be working as expected.
Solution: Check your code syntax, compare $_POST keys, and debug using the server logs.
Problem: I am using CRED to create child posts. I would like to programmatically set the child post title based on the parent post title. I'm using the beta plugins.
Solution:
The post data key for accessing the parent post's ID has changed in the M2M betas. You can now use the format "@" + relationshipslug + "_parent". In this case the relationship slug is member_visitation, so the key is "@member_visitation_parent".
add_action('cred_save_data', 'copy_parent_title_to_child',10,2);
function copy_parent_title_to_child($post_id, $form_data)
{
// if a specific form
if ($form_data['id']==429)
{
if (isset($_POST['@member_visitation_parent']))
{
$my_post = array(
'ID' => $post_id,
'post_title' => get_the_title($_POST['@member_visitation_parent'])
);
wp_update_post( $my_post );
}
}
}