georgiI
Support threads created in the last 30 days: 1
Favorite Forum Topics
This user has no favorite topics.
Forum Topics Created
Status | Topic | Supporter | Voices | Posts | Freshness |
---|---|---|---|---|---|
Include custom fields into toolset forms from other plugin
Started by: georgiI in: Toolset Professional Support |
2 | 11 | 6 months, 2 weeks ago | ||
Assign first uploaded image from repeating image field as featured
Started by: georgiI
in: Toolset Professional Support
Problem: How to set the first uploaded image of a front end form which is a repeating field without using the WordPress Media library mode to be the posts featured image? Solution: Add the custom code below to Toolset: add_action( 'cred_save_data', 'tssupp_make_featured_image', 10, 2 ); function tssupp_make_featured_image( $post_id, $form_data ){ $image_field = 'pictures'; // edit field slug if ( in_array( $form_data['id'], array( 123 ) ) ) { // edit form ID // get the images $images = get_post_meta( $post_id, 'wpcf-'.$image_field, false ); // get the attachment ID of the first image if ( is_array($images) ){ $first = attachment_url_to_postid( $images[0] ); if ( $first > 0 ){ // set the featured image update_post_meta( $post_id, '_thumbnail_id', $first ); // delete the first custom field image delete_post_meta( $post_id, 'wpcf-'.$image_field, $images[0] ); } } } } Replace "id" with the form ID and replace "pictures" with the repeating custom field that you use for the images.
|
2 | 12 | 8 months, 2 weeks ago | ||
Assign first uploaded image from repeating image field as featured
Started by: georgiI in: Toolset Professional Support |
1 | 3 | 9 months ago |