[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.

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.

Related documentation: Content Templates

This topic contains 4 replies, has 2 voices, and was last updated by  guyM-4 2 weeks ago. The support staff assigned to this topic is Shane.

Viewing 5 posts - 1 through 5 (of 5 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

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

You are not logged in. You can view support threads, but not post.
If you are already logged in, please refresh your browser.