Skip Navigation

[Resolved] CRED Form Limit Number of File uploads by Role w/ WooCom Upgrade

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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 5 replies, has 2 voices.

Last updated by Beda 7 years, 11 months ago.

Assisted by: Beda.

Author
Posts
#373087

I am trying to: Limit users from upload glut in CRED form per role and employ WooCommerce to charge for additional as singles or packages (5, 10, 20...). Default setup would be per user Role A = 5, Role B = 10 after reaching default threshold they are asked to buy a package. WooCom would issue upload credits and subtract from unit balance.

BTW: My current form config allows for one upload at a time. Toolset is all latest versions.

I visited this URL: https://toolset.com/forums/topic/limit-number-uploading-files/

I expected to see: A brilliant mind.

Instead, I got: An empty skull.

#373334

The setup you require is complex, and not doable with a simple JavaScript function.

CRED does not support natively any check for amount of Files upload.

You could work with that JS function provided in the linked post, or with a CRED API validation code.
https://toolset.com/documentation/user-guides/cred-api/#cfv

It requires a advanced application logic, since you also involve WooCommerce and want to redirect to Forms with payment in case the amount of Media Uploaded is reached.

I am not sure if your Media will be a types Media repeatable field, or native WordPress Media, or even a standalone Post.

What i would suggest is actually a mix of different forms, which are conditionally displayed with Access according the Role.
https://toolset.com/documentation/user-guides/access-control-for-cred-forms/

Each Form creates the same Post Type eventually, but would hold different Fields (as example a single instance Media field for Role A and a repeatable instance for Role B)

On Role B CRED forms you apply a Custom CRED API validation to check the repeatable instance is not greater than 5 or any amount of instances.

To let the user buy a package you will need yet another Form, as elaborated here, you need a CRED Form for each Product / package you want to let the user pay the additional uploads with:
https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/

Also, actually the user should hold a Custom Field, so you can additionally evaluate by this field if the user is allowed to upload more images (after a purchase), otherwise it will simply keep the Role evaluation and never let the user to upload more images.

Also this would require a Custom CRED API code to update the User Meta on the fly when you submit the payment form.
For this you will use this Custom API function:
https://toolset.com/documentation/user-guides/cred-commerce-api/

The easier approach is actually to let the user decide from the first registration on your Site how much media he / she wants to upload.
Then, according to this you will register the user with a specific CRED Form that automatically will add the product / payment.
This will then create the user in the specific role, and allow the user to upload [xy] amount of media according your validation settings.
https://toolset.com/documentation/user-guides/cred-user-forms/
https://toolset.com/documentation/user-guides/charging-payments-with-cred-to-register-users/

Please let me know if you have further questions regarding the issue mentioned in this Thread

Thank you for your patience.

#373621

Complex indeed. Let me absorb your information and create a user flow map and take a closer look. I will update once I've done this.

#373679

Sure, I will expect your infos here in the forum.

Keep in mind this Thread will be auto-closed (not without prior email notification to you) by the "Friendly Clean Up Robot" in 30 days from now.

Please let me know if you have further questions regarding the issue mentioned in this Thread

Thank you for your patience.

#380289

Still working on application while reading docs and testing methods. Will update.

#380441

Sure, this thread will again stay open 30 Days from now.

The Friendly Clean Up Robot will get in touch with you before closing the Thread if the time is up

Thank you

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