[Resolved] Multiple templates (per role) for same custom post type

This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Our next available supporter will answer your ticket in about 5.80 hours from now. Thank you for your understanding.

Related documentation: Content Templates

This topic contains 5 replies, has 3 voices, and was last updated by  John Johansen 2 months, 1 week ago. The support staff assigned to this topic is Shane.

Viewing 6 posts - 1 through 6 (of 6 total)
Author
Posts
#576502

I'd like to define multiple templates for the same CPT depending on the custom role: for instance, if you have the custom role A and display the page for a given CPT, you see it with a certain layout, but if you have the custom role B, when you display the same CPT, you see it with a different layout.
The idea is that A users are able to create CPT and edit some informations in them, while B users review the CPTs created by A users and can see/edit different aspects of the same CPT. I'm putting CRED forms in those layouts, and those can be differentiated using Access Control, but content of the layout needs to be different also.

Any help would be appreciated.

#576617

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi Guy,

Thank you for contacting our support forum.

Actually you wouldn't be able to use multiple template for different users however you can use our conditional shortcode to change the display per user.

Take a look at our conditional shortcode usage .
https://wp-types.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

Also this is the shorcode that you would need.
https://wp-types.com/documentation/user-guides/views-shortcodes/#wpv-current-user

You can use the shortcode above along with our conditional to evaluate the role of the user and then change how the content is displayed based on the role.

Please let me know if this helps.

Thanks
Shane

#576654

Hi Shane,

Thanks for the quick reply.
I'm not entirely sure how I'm supposed to use these shortcodes: today I have a single Layout defined for my CPT, its content is defined with the Layouts editor. Are you saying I should add to that template all the elements of the second template I need for the same CPT, and bracket each element with a conditional?
That sounds a bit cumbersome and convoluted.

#576678

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi Guy,

What I'm saying is that you will be able to use the conditionals to separate the designs within 1 template.

For e.g
[wpv-conditional if="( '[wpv-current-user info="role" ]' eq 'administrator' )"]
Design A goes here
[/wpv-conditional]
[wpv-conditional if="( '[wpv-current-user info="role" ]' eq 'author' )"]
Design B goes here
[/wpv-conditional]

This is what i'm making reference to so admins will only see design A and authors will only see design B

Please let me know if this helps.
Thanks,
Shane

#576690

Hi Shane,

OK that's what I understood. Not ideal if the layouts are very different, but I see there aren't many other options.

Thanks for your help

Guy

#585483

Guy:

Did you have any success in implementing the proposed solution of multiple designs within a single template?

Any feedback you could provide would be appreciated.

I am trying to come up with an appropriate solution to the same general problem of displaying a given CPT in a customized way for each of multiple user types/roles.

I have the Groups plugin installed, and it can control content based on group membership/capabilities. The page functional elements must be enclosed within a Groups shortcode in order to control whether they are displayed. However, using the Toolset Layouts plugin, the only Layout element that supports this technique is the Visual Editor because none of the other Layout elements provide the capability to enclose the rendered code within the Groups shortcode. So, I may have to employ the approach described above. My main concern is whether I can get the Toolset conditionals to test for Groups-based user metadata.

John

Viewing 6 posts - 1 through 6 (of 6 total)