Skip Navigation

[Resolved] CRED product edit form custom images resets the featured image

This support ticket is created 8 years 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Pagel 8 years ago.

Assisted by: Luo Yang.

CRED issue 1.PNG


I have some issues with CRED product edit form. Here is my setup:

[credform class='cred-form cred-keep-original']

[cred_field field='form_messages' value='']

<div class="cred-field cred-field-post_title">
<label class="cred-label">
Product Name
[cred_field field='post_title' post='product' value='' urlparam='']

<div class="cred-field cred-field-post_content">
<label class="cred-label">
Product Description
[cred_field field='post_content' post='product' value='' urlparam='']


[cred_field field='_regular_price' post='product' value='' urlparam='']

[cred_field field='pa_condition' display='checkbox']

Product Category
[cred_field field='product_cat' display='checkbox']

Featured Image
[cred_field field='_featured_image' value='' urlparam='']

Media Gallery
[cred_field field='my_product_image_gallery' post='product' value='' urlparam='']

[cred_field field='form_submit' value='Submit' urlparam='']


I have created a custom post to upload more images alongside with featured image. The issue is that when I upload a new image for "my_product_image_gallery" it will delete the featured image. Also I have added CRED_save_data hook to copy images to product image gallery using help of

add_action('cred_save_data', 'my_save_data_action',10,2);

function my_save_data_action($post_id, $form_data)

// if a specific form
if ($form_data['id']==285)
$iamge_url_arr = get_post_meta($post_id, 'wpcf-my_product_image_gallery');
$iamge_id_arr = array();
foreach($iamge_url_arr as $img){
$iamge_id_arr[] = prefix_get_img_ids($img);
$value = implode(',', $iamge_id_arr);
update_post_meta($post_id, '_product_image_gallery', $value);

function prefix_get_img_ids($img='') {
$id= '';
global $wpdb;
$query = "SELECT ID FROM {$wpdb->posts} WHERE guid='$img'";
$id = $wpdb->get_var($query);
return $id;

This is working fine but if I edit/add images to my_product_image_gallery then the featured image is removed and the image I added is not updated to product gallery. Please see the attachment. Why it is showing all this text and two images in the cred form?

There are also issues with price: Price There is a problem with _regular_price field. Please check CRED form. I have made _regular_price available from hidden custom posts in the toolset settings but it is not appearing anywhere in the CRED wizard.



Dear Pagel,

Q1) Why it is showing all this text and two images in the cred form?

I just tested the the CRED form codes and the custom PHP codes in my localhost, it works fine, I suggest you try this:
1) Make sure you are using the latest version of Toolset plugins
2) Deactivate other plugins and switch to wordpress default theme, and test again

Q2) Price There is a problem with _regular_price field. Please check CRED form.
Since the custom field "_regular_price" is not created with Types plugin, and the Toolset Settings-> Hidden custom fields, which works for Views plugin only, does not work for CRED plugin, so I suggest you add a generic field into your CRED for the field "_regular_price", for example replace this line from:
[cred_field field='_regular_price' post='product' value='' urlparam='']

[cred_generic_field field='_regular_price' type='numeric' class='' urlparam='']
"default":"[wpv-post-field name="_regular_price"]"

More help:



Thanks for that!

Q1) I figured it out. It was Jetpack Photon option that made the images to show up twice. Photon was active as a default and inactivating it fixed the issue.

Q2) Thanks that fixed the issue.

Another issue popped up. My custom my_product_image_gallery is not working properly anymore. I have multiple products in the view and when I edit/add new image gallery image for any other product than the first one it will upload the image to the first product in the view. This happens with the first image. When I add the second image, it works fine.

Not sure I explained that thoroughly enough.

Another question, not sure if I should open a new thread but it connected to that cred_save_data hook. What need to be done in order that the images will be uploaded to media gallery when forming a product via CRED form? (that above piece of code works fine for editing products but what to modify or add to include it also to new products?



Q3) Another issue popped up,
Thanks for the feedback, I can duplicate same problem in my localhost, and put it into our to-do list, our developers will take care of it.
Currently, I suggest you setup a CRED edit from link instead of displaying the CRED form directly, then there should be only one form in one page, see our document:
section "Inserting editing Post Forms and deletion links"

Q4) Please create different threads for each question, it will help other users to find the answers. thanks



Okay I will use cred forms that way until it is fixed.

Ok, I will make another thread.


This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.