I am trying to: require a featured image to be uploaded in a CRED form
I previously reported this at: https://toolset.com/forums/topic/i-want-to-require-a-feature-image-be-uploaded/
I tried the fixes suggested without luck... I also saw https://toolset.com/forums/topic/required-featured-image-code-not-letting-me-load-any-featured-image/.
Here is he problem as I described before:
"I have upgraded all plugins and still have the same problem... The form does not recognise that a featured image has been uploaded when one has.
The image uploads... is visible in Media (in the WP Backend) but I still cannot submit my form ... it gives me the error:
“The post was not saved because of the following problem:
Featured Image: This field is required”
any ideas?"
Peter
I am still having the problem can you please help?
Hello Peter,
Thank you for contacting Toolset support.
I’m Mohammed: the Toolset support team leader. I’ll give my best to help you to achieve your needs through Toolset components.
We didn't get similar issues reported from our clients. I doubt that this may be a conflict with another plugin or a custom code.
So, please try the following:
- Deactivate all non-Toolset plugins and activate the default theme (Twenty sixteen)
- Comment out any custom coding
- Backup your .htaccess file and go to settings > permalinks and click save changes
- Test the issue and share the results with me.
If the issue hasn't been resolved be following the previous steps, please provide me the access to your admin dashboard and FTP files so that I can check the issue.
I will set the next reply as a private one so that you can share the credentials securely.
Also, please guide me to replicate the issue, you may mention the page that the form exists.
Thanks.
Hi Peter,
I'm posting this to set the next reply as a private one as well.
Thanks.
Hi Peter,
The custom code should solve the issue temporarily but, if we need to fix the issue permanently, we apply a hotfix that will be included in a future release.
Here is a link for an Errata page that contains the fix for your issue: https://toolset.com/errata/featured-image-uploaded-not-attached-posts-created-using-cred-form/
Please follow this errata page instructions, remove the wpengine cache and remove the browser cache and test the issue and let me know if this errata fixes your issue.
Thanks.
Glad to know it isn't just me
This looks good but I have yet to implement... hopefully tomorrow...please keep this support request open for a bit longer. Cheers
Peter
I applied the suggested fix which did not work (I do note the fix you referred me to was for an issue that was resolved in a later upgrade of CRED... which I had already installed... I also had a custom fix applied to a related problem by Nigel earlier.)
Can you please have a look and suggest how I can resolve this problem... I have provided login details previously.
Kind regards
Peter
Hi Peter,
I see that this page (Make an appointment) has a javascript error which may prevent CRED of uploading the image properly. please check the attached screenshot.
This should be a conflict with another plugin/theme.
If it's not the case, I will need to replicate the issue on my localhost so that I can debug the issue locally.
For that, I will need a copy of your website to work on.
Because, you are using wpengine, you will not be able to use a plugin to prepare a copy of your website, So, please kindly prepare an archive that contains a database dump and the website files and upload it to an uploading platform like Google drive then provide me the downloading link in the next private reply.
Thanks.
Hi,
I'm in contact with Nigel regarding that.
I will post here again to update you.
Thanks.
Hi,
Nigel doesn't have a copy of your website right now. because, we usually, delete the clients websites when we finish working on an issue.
Anyway, he used the "All in One WP Migration" plugin to create a copy of your website.
Could you please try it? I will set the next reply as a private one so that you can provide the package securely.
Thanks.
Hi Peter,
I've tried to download the achieve but I couldn't.
This may be Due to the large file size.
I'm trying again and if I failed, I will post here again.
Thanks.
Hi Peter,
I tried more times to download the package but I failed.
Could you please try to provide another package without the uploads and any caching?
I think that the allinone plugin provides an options to exclude directories.
I'm setting the nex reply as a private one so that you can provide the package download URL.
Thanks.
Hi Peter,
Thank you for your patience.
Finally, I was able to download and replicate your issue locally.
You have some custom code in your functions.php in the sparkling-child theme.
In this function : my_validation , there should be a line of code at the beginning of the function body
Could you please add the following line to this function:
list($fields,$errors)=$field_data;
So that the function will be like the following:
add_filter('cred_form_validate','my_validation',10,2);
function my_validation($field_data, $form_data)
{
list($fields,$errors)=$field_data;
//validate if specific form
if ($form_data['id']==1564)
{
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) and !empty($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) != 'xmlhttprequest') {
if (!isset($_POST['_wpcf_belongs_company-profile_id']) or (isset($_POST['_wpcf_belongs_company-profile_id']) and $_POST['_wpcf_belongs_company-profile_id']==""))
{
//set error message for my_field
$errors['_wpcf_belongs_company-profile_id']='To make an announcement you must be logged in, authorised and make the announcement via the "Make an Announcement" button on your company profile';
}
}
}
//return result
return array($fields,$errors);
}
I can't test the issue right now because the admin credentials you sent me don't work.
So, please test the previous code and let me know if this works.
I'm setting the next reply as a private one so that you can provide the credentials in case we needed them later.
Thanks.
Thanks so much for this... solution tested and works...
Mohammed
I have hit a problem... After getting everything working with your fix I updated the CRED plugin from version 1.8.2 to 1.8.4... the fix you provided no longer worked... well not completely... the Announcements form enabled me to upload an image this time... but although the image was saved to the media library it was not set as featured image for the Custom post.
The steps I took were to revalidate my staging site then update the types plugin (which you have to do to update the CRED plugin)... I then tested the announcements form ... it worked fine... image set as featured image - all good.
I then updated the cred plugin and re-tested.. and got the above results.. image not set as featured image
Any ideas??
Could you please reopen the ticket and I can give you fresh login credentials.
Cheers
Peter
Hi Peter,
The original thread issue was not related directly to CRED as it was a fault in the code added to your functions.php file.
The new one you mentioned in the last reply may be a different issue.
May I kindly ask you to mark this ticket as resolved and open a new one for the new issue?
We will try to handle it ASAP.
Thanks.