Skip Navigation

[Closed] the conditional block does not respond to access permission levels

This support ticket is created 2 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
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: Africa/Casablanca (GMT+01:00)

This topic contains 7 replies, has 3 voices.

Last updated by Jamal 2 years, 6 months ago.

Assisted by: Jamal.

Author
Posts
#2184273
Rendered page from both codes  and conditional block on the same page.JPG
Conditional level handle by access short code.JPG
conditional block with same permission leve same page.JPG

I need to create a permission level in a page.

I used the conditional block to authorize a user with multiple roles with a specific permission level to have access to a determined information. The conditional block rendered zero results.

However when I used the Toolset Access code [toolset_access role="any desired level within a multiple roles list" operator="allow"]Display something if current user has "the intended permission level"[/toolset_access] the access code read the each individual permission level and authorized the level in question to have access to the intended info.

If Access was able to detect a single role from within a multiple list, why the conditional block was not able to authorize the same role authorized by access? isn't it the same process for authorization once the permission level was met?

Is the conditional block a weaker feature?

#2184493

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+01:00)

>Is the conditional block a weaker feature?

In this particular case, yes. The test for "Current user role" only returns a single role, not a list of roles where a user has multiple roles assigned.

To test against multiple roles using the conditional block would require writing a custom function or custom shortcode to perform the check.

#2185769

Thanks Nigel,

That helps. I was going crazing adding and delete through a whole bunch of testing thinking where was my mistake. Knowing that the block feature is limited to a single user role does help.

Now, if I keep using the access toolset code directly in the page, will it provide me a good integration with all other blocks while maintaining the permission levels for content at a optimal level with no breaches or compromises to my membership website? in other words, can I trust this code
[toolset_access role="any desired level within a multiple roles list" operator="allow"]Display something if current user has "the intended permission level"[/toolset_access] ?

#2186033

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello there, this is Jamal from Toolset support. Nigel does not work on weekends.

Yes, you can rely on the toolset_access shortcode, but you won't be able to put blocks inside of it. You can only put shortcodes. You can put a content template, built using blocks, inside of it using a shortcode:

[wpv-post-body view_template="Name or slug of the content template"]

As Nigel suggested you can add a custom function or shortcode and use it with the conditional block. Remember that you will need to register it in Toolset Settings. Check an example here https://toolset.com/forums/topic/conditional-display-using-current-user-role-is-not-working/#post-1962461

I hope this helps. Let me know if you have any questions.

#2186399

Thanks Jamal. that was good help too. I appreciate it.

Now, I kind of created my own crazy solution and it is kind of responding well thus far. I used the way below. I know it may be cumbersome and a function would be more neat, but it feels I would have more control and easy to follow (through the 150 plus pages and many pages/post/content templates and views with several permissions levels on the same page/post) or trust my maintenance dev to skim through without much complication (php mess ups). I have a CMS with about 26 different roles, which many roles have multiple capabilities running through 22 post types for a 10K-15K users in a membership site.

In the blocks editor I formatted this way:

1-Field and Text block just with the access code -> [toolset_access role="any desired level within a multiple roles list" operator="allow"]

2- Added in separate block(s) with the intended info/blocks/content for the specific targeted audience

3-added another field and text block just with the toolset access closing tags -> [/toolset_access]

If I do this way, will it be problematic instead of a function set up?
Toolset is very powerful and I have my websites running entirely on all toolset plugins. (I don't even use Guttenberg or Kadence).

Thanks

#2186655

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Well, If you are not using the Gutenberg editor, then what I said is not really relevant. You can continue to use the Toolset Access shortcodes without issues.

But, you talked about the "Fields&Text" block, which lets me think that you are actually using the Gutenberg editor. In that case, you may test with HTML blocks like this:
1. HTML block that contains the opening Toolset Access shortcode [toolset_access role="any desired level within a multiple roles list" operator="allow"].
2. Put the blocks after it.
3. HTML block that contains the closing Toolset Access shortcode [/toolset_access].

I am suggesting the HTML block because it won't wrap its content in HTML tags, while the "Fields&Text" block will wrap its content in a <div> tag.

Does it make sense?

#2187093

thanks Jamal,

It does make sense. I see your point. I meant I am not using the Gutenberg blocks or any other blocks outside the Toolset available ones. But you are right, having it wrapped in div tags it may hinder the code functionalities. I agree that html tags will make the code cleaner.

Thanks, I will do that.

#2187659

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Awesome, please let me know what you will get.

I'll set this ticket as waiting for your feedback, which should keep it open for a couple of weeks. You should receive email notifications before it gets closed by the system.

The topic ‘[Closed] the conditional block does not respond to access permission levels’ is closed to new replies.