If I implement this and then use a form to create a post which also includes an audio file attachment, the audio url gets used as the featured image url when the featured image is chosen from existing media library files.
I am unclear if I can use the errata example code as is or whether it needs amendment
Can you please confirm that if you remove the following code from your functions.php file - you do not see that featured image URL is set same as the Audio field URL:
add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data){
//put whatever control in place to act only on given forms (if cred form ID == etc etc)
//get all child posts to the post we created/edited, this is how attachments are bound to their "parent" or owner posts
$args = array(
'post_parent' => $post_id,
'post_type' => 'attachment',
);
$attachments = get_children( $args );
//If there are attachments, get their ID and update the current post meta _thumbnail_id with it
if ( $attachments ) {
foreach ( $attachments as $attachment ) {
update_post_meta($post_id, '_thumbnail_id', $attachment->ID);
}
}
}
Can you please share FTP access details as well.
I have set the next reply to private which means only you and I have access to it.
I apologize to chime in here, I can currently not update the erratum, but would have a solution to try, hence I share it here.
Please let Minesh know if this works for you as well once tested preferably on a testing site (I tested it extensively and found no issue)
add_action('cred_submit_complete', 'my_success_action',10,2);
function my_success_action($post_id, $form_data){
//put whatever control in place to act only on given forms (if cred form ID == etc etc)
//Get the value of the Form INPUT, which is the attachement URL
$url = $_POST['_featured_image'] ? $_POST['_featured_image'] : '';
//Update the postmeta with the ID of that attachement, if existing
update_post_meta($post_id, '_thumbnail_id', attachment_url_to_postid($url));
}