Skip Navigation

[Resolved] Conditional display for form input set by WP user role

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

Problem:

I want to create forms for creating and editing them, but I want to allow only specific WP roles ( Extended CPT Author) to be able to upload image to this CPT, others (Basic CPT Author) can not upload that , only able to set the CPT's Title and Content.

Solution:

I suggest you try with Access shortcode [toolset_access], check if current logged-in user has specific user role "Extended CPT Author", then display the show image upload option.

Relevant Documentation:

https://toolset.com/documentation/user-guides/access-control/access-control-texts-inside-page-content/

This support ticket is created 4 years, 3 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 6 replies, has 2 voices.

Last updated by Vane 4 years, 3 months ago.

Assisted by: Luo Yang.

Author
Posts
#1441229

Hi,

I have a custom post type (CPT) which has a Title (single line text), a Content (Multiline Text) and an Image custom field (CF).
I want to create forms for creating and editing them, but I want to allow only specific WP roles ( Extended CPT Author) to be able to upload image to this CPT, others (Basic CPT Author) can not upload that , only able to set the CPT's Title and Content.
I don't want to allow to upload any other type of file and I want to allow 1 per a specific CPT (like a Featured Image).
I do it for security reason.
I've set up Access to manage this CPT, copying the Author capabilities of default posts to this CPT.

I've already read this:
https://toolset.com/documentation/user-guides/front-end-forms/conditional-display-for-form-inputs/

Reading the above I supposed I can set up much more general conditions in a Form Conditional Group, but I can't!
I wanted like this:
IF user role = 'Extended CPT Author' THEN show image upload option, ELSE don't.
I can only set up such conditions which are related to CF Group used with that specific CPT, but not such standard WP post, term or user conditions!

Any solution idea or workaround is appreciated,
thank you!

#1441703

Hello,

I suggest you try with Access shortcode [toolset_access], check if current logged-in user has specific user role "Extended CPT Author", then display the show image upload option.

See our document:
https://toolset.com/documentation/user-guides/access-control/access-control-texts-inside-page-content/

#1442107

Hi,

I gonna check your idea, thank you.
Could you send me a link to Access shortcodes page (like Views and Forms have), I don't find them googling even
"Access shortcodes site:toolset.com"
string,
and I need the available shortcode parameters.

In other threads client was referred to use
Views conditional output
( https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/ )
where we can use much more conditions to evaluate.

Will it work in a form definition, in my case?

Thank you

#1442163

There isn't existed Access shortcodes document page.

For the question:
where we can use much more conditions to evaluate.
Will it work in a form definition, in my case?

In your case, I suggest you try with Access shortcode [toolset_access], [wpv-conditioal] shortcode might involve some custom codes.

#1442237

Then how others work with Access shortcodes, if they don't know the available parameters and valid values?
Also, in Form Editor, even in Expert Mode, Access elements are not available.

Even if I want to create this Access shortcode in a test page ( supposing I gonna have an Access GUI or like that there), Access elements are not available in Block Editor and also not available in Classic Block, where Views, Forms, Conditionals are available

I'm afraid I have to drop this idea and figure out a totally different approach...

#1443817

Thanks for the details, you are right, there isn't button for Access control within Toolset form editors, you can add a feature request for it:
https://toolset.com/home/contact-us/suggest-a-new-feature-for-toolset/
Our developers will evaluate it.

Currently, you can setup the access shortcode manually, for example:

[toolset_access role="Extended CPT Author" operator="allow"]
here ...
[/toolset_access]

Please replace "Extended CPT Author" with your custom user role's name

#1444651

Thank you!

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