Skip Navigation

[Escalated to 2nd Tier] Pics are removed when custom post is edited

This support ticket is created 5 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/Karachi (GMT+05:00)

This topic contains 19 replies, has 3 voices.

Last updated by Waqar 4 years, 6 months ago.

Assisted by: Waqar.

Author
Posts
#1232851

The video explains better: hidden link

#1233255

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Felipe,

Thank you for contacting us and sorry about the delay, as we had an unusually busy queue.

From your video, I understand that in the image field's settings, you have set a "Conditional display" to only show it when the value of other radio fields (allow editing of images) is set to "yes".

The way "Conditional display" option from the field's own settings works, it is automatically applied to the admin area (post editing screen) and the front-end forms. An important thing to note is that this option doesn't remove the set custom field values if they're set, but only hides the interface/fields to edit them.

Also, when an image is removed from an image custom field, it is not automatically deleted from the website's media library.
( whether it is removed from the post edit screen in the admin area or through the front-end form )

If you'd like to have more flexible control over the conditional display of fields, you can remove it from the field's settings and instead use the conditional blocks for the front-end display ( e.g. inside the views or content templates - ref: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/ ) and the conditional form field blocks, for the front-end forms ( ref: https://toolset.com/documentation/user-guides/conditional-display-for-form-inputs/ ).

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1233428

You totally did not get the point. The conditional display is fine. What I was referring to was the images being removed from the custom post after the user edits his/her post.

Please review the video again and you will see that the images disappear after editing the form.

Thanks

#1233794

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Felipe,

Thanks for writing back and I apologize for the confusion earlier.

During testing on my own website, I was able to reproduce this behavior.

When based on the condition, an image field is not shown in the form for editing and the form is submitted, the added custom field images are removed from that field as well.

I'm going to share these findings with the concerned team for further review and will keep you updated with the progress through this ticket.

For now, you can create a clone of your post editing form and from one of the forms remove the image field, that you don't want to present to some users.

This way, you'll be able to show the form with the image field, for some users and the other one without it for the rest, using the conditional blocks.
( ref: https://toolset.com/documentation/user-guides/conditional-html-output-in-views/ )

Example code to load the correct form, based on the selected value from the allow image editing field:


// With image editing
[wpv-conditional if="( $(wpcf-allow-image-editing) eq '1' )"]
[cred_form form='form-to-edit-a-dish-with-image-field']
[/wpv-conditional]

// Without image editing
[wpv-conditional if="( $(wpcf-allow-image-editing) eq '2' )"]
[cred_form form='form-to-edit-a-dish']
[/wpv-conditional]

Note: Please replace form and field slugs and values, with the actual ones used on your website.

regards,
Waqar

#1233802

Thankfully the site is not live just yet. So I will wait to hear from the concern team before implementing the conditional blocks.

Thank you and looking forward to your reply.

#1234140

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

You're welcome Felipe and appreciate you brought this forward.

I'll keep you updated through this ticket.

regards,
Waqar

#1236599

Waqar I need to finish the website so I followed your suggestion about the form with conditions but it is not working. I followed your instructions to the T.

See the video: hidden link

I don't know what is wrong.

P.S. - I'm not using the Content Template for this. I mention in the video.

#1236822

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Felipe,

The first thing that I would check is the custom field which controls whether the image editing should be allowed or not.
( screenshot: hidden link )

In my example, I used the values '1' and '2', because, in my field group's settings, I used those values.
( screenshot: hidden link )

But on your website, that custom field can be set to use different values, e.g. yes or no. Please make sure you're using the correct values in the conditional blocks.

Next step should be to narrow down if the conditional blocks aren't working or the edit forms are not rendering. To start troubleshooting, you can remove the form's shortcodes from inside the conditional blocks and add some simple text lines to see which of the two conditional blocks are getting processed.

Once it is confirmed that the conditional blocks are working, you can move to the part of including the form's shortcode.

These steps will help in the troubleshooting because you're not adding this in regular Toolset content template and are using the Elementor page builder.

In case the issue still persists, you're welcome to share temporary admin user's details for further troubleshooting.
(I've set your next reply as private, just in case you need to share the access details)

regards,
Waqar

#1237520

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Felipe,

Thank you for sharing the access details.

I've checked the set up of your website's pages and noticed that you are using a single regular page to show the edit form.
hidden link
( hidden link )

The URL parameter "f_editar" is being used to specify which "anuncio" post item should be used for editing.

Since this page is not a single "anuncio" post item page, the information of custom fields like "wpcf-deixar-anunciante-mudar-fotos" cannot be called in, directly here and this is why the conditional blocks are not working either.

A simple way to overcome this scope issue is to create a new view, which is set to show the "anuncio" post item, whose ID is available in the URL parameter "f_editar".

Please refer to the view named "View to show the correct edit form conditionally" and see how it's "Query Filter" is set.
( ref: hidden link )

Inside this view, you can call in the current "anuncio" post item's custom fields directly and the conditional block also works.

I hope this helps and please let me know if you need any further assistance around this.

regards,
Waqar

#1237729

Waqar, it worked!

But the only thing is that, let's say we allow this customer to change their pics for now... then in the future we decide to disallow because the client is misbehaving, when I change back to "not allowed," the information that was on one form changes to the other. And that will cause problems in the future.

So maybe the development team needs to look into fixing the conditional output as first mentioned. Maybe prioritize such matter.

#1237777

Waqar,

I was thinking, but I don't know if it's possible. Maybe have two forms (one with the custom fields image and another with everything else), then link the two forms together, that way we could show or not show the custom field image one, that way the information on the other custom fields would not be affected.

Is that possible?

#1238032

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Felipe,

To recap, we are now using two identical edit forms for editing and the only difference is that one brings in the image custom field and the other doesn't.

Since all the other fields will remain the same, I don't see how the user information will be affected if a different form is switched for editing the same user.

Likewise, you can try the approach of using two separate forms, one for the image fields and the other for all the other fields, but I don't see any drawback of using the current approach, which is already in use.

As for the original issue itself, our development team is working on this and a fix is planned to be included in the 2.4 version of Toolset Forms plugin.
( https://toolset.com/errata/toolset-forms-deletes-image-postmeta-if-field-is-conditionally-hidden-in-the-form-even-if-the-field-has-a-value-saved/ )

I'll keep you updated with the progress through this ticket.

regards,
Waqar

#1238188

Waqar,

I'm sorry, I know what happened. While I was testing, I did not refresh the page where I allow or disallow the user to change the images, therefore, it was using the previous settings instead of the new settings it was established. I was my fault for not refreshing the page. Sorry about that.

Thanks for your help so far, I'm looking forward to the new version of Toolset Form.

#1238453

Waqar
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

Hi Felipe,

Happy to help and glad it is sorted out.

Will let you know once the release with the fix is out.

regards,
Waqar

#1278769

What's the status on this please?