Skip Navigation

[Resolved] Uploading image file in CRED Editing Form requires Admin privilege

This thread is resolved. Here is a description of the problem and solution.

Problem:
Guests who have Access permissions to a CRED form are unable to upload images in a custom field. An error is shown "There was an error uploading your file.

Solution:
I see this issue is already reported in our internal ticket system to our Devs and its known to us.

Please open a new ticket if you see this issue on your own site.

Relevant Documentation:

This support ticket is created 6 years, 6 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 5 replies, has 2 voices.

Last updated by jeffS-2 6 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#873990
ScreenShot - Image Upload Error.png

I am trying to: CRED form was working fine for 3+ years for uploading a portrait image (type Image). Now, for some reason only admins are able to complete the upload. Other users receive "There was an error uploading your file" shortly after the progress bar begins. I looked in ACCESS but don't see anything particular about uploading images. I don't know if I changed something and caused this, or if it may have been caused by a Toolset update, or what. Any ideas where I might take a deeper look or what to check?

Link to a page where the issue can be seen:
Requires Member Login.

#875459

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - could you please give me problem URL and access details so I can check whats going wrong there.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#900914

Minesh
Supporter

Languages: English (English )

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

I see this issue is already reported in our internal ticket system to our Devs and its known to us.

This is the workaround shared by Devs - I've added following code to your current theme's functions.php file:

add_action( 'admin_init','reset_guest_caps' ,9 );
function reset_guest_caps(){
    global $current_user, $wpcf_access;
    if(isset($_GET['formid']) && $_GET['formid']==22327 && $current_user->ID==0){
        $wpcf_access->settings=array();
    }
}

I see now with your CRED form file upload is working with guest user. Could you please confirm.

#901175

Great! Thanks for this, Minesh.

Is there a reason we need to check for $current_user->ID == 0 ?
I realize the form I pointed you to was for users NOT logged in, but I have another (edit) form that also allows upload of an image file. I removed that part of the if statement and it seems to work fine for both forms. I just wonder if not checking the user ID poses any potential problem.

Thanks,
Jeff

#901628

Minesh
Supporter

Languages: English (English )

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

Is there a reason we need to check for $current_user->ID == 0 ?
==> I think the issue is for only guest users, that is why we are checking the user ID = 0.

I realize the form I pointed you to was for users NOT logged in, but I have another (edit) form that also allows upload of an image file. I removed that part of the if statement and it seems to work fine for both forms. I just wonder if not checking the user ID poses any potential problem.
==> Please check if you have issue with edit form then as you said remove the ID and use the code.

#901709

Thanks, Minesh.
Yes, it works fine without the check for user ID.

Jeff
---------------------