Skip Navigation

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

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 6 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.
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.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

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

This topic contains 5 replies, has 3 voices.

Last updated by John Johansen 6 years, 6 months ago.

Assisted by: Shane.

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
Supporter

Languages: English (English )

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://toolset.com/documentation/user-guides/conditional-html-output-in-views/using-shortcodes-in-conditions/

Also this is the shorcode that you would need.
https://toolset.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
Supporter

Languages: English (English )

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

The forum ‘Types Community Support’ is closed to new topics and replies.

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