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?
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.
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] ?
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"]
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).
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.
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.
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.