Skip Navigation

[Resolved] The published errata for Forms issue with Amazon S3 is causing a further issue

This support ticket is created 5 years, 3 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.

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

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 3 replies, has 3 voices.

Last updated by Minesh 5 years, 3 months ago.

Assisted by: Minesh.

Author
Posts
#1333249

I have a problem with the errata https://toolset.com/errata/issues-with-saving-images-and-media-fields-in-toolset-forms-when-using-amazon-s3-and-cloudfront-plugins/

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

#1333399

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

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.

#1334199

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));
}
#1334727

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please try the solution that Beda shared with the previous reply and let me know your feedback how it goes.