Skip Navigation

[Resolved] Create post with access by user role

This thread is resolved. Here is a description of the problem and solution.

Problem:

But i need made lesson 'private' (only teacher can view) by checkbox.

For example i have 10 lesson but one lesson as private - i check in checkbox "for teacher" and when guest or other user role show lesson archive they see 9 lesson, private lesson not shown.

Solution:

You might consider other workaround, for example, create another post type "Teacher only lessons", use Access to setup the limitation to this post type, so other user role won't be able to access posts of post type "Teacher only lessons".

Relevant Documentation:

This support ticket is created 4 years, 1 month 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: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Rostislav Avtodiychuk 4 years, 1 month ago.

Assisted by: Luo Yang.

Author
Posts
#1780753

Tell us what you are trying to do?
Hello we made site for school and we have CPT - lessons, two user roles - teacher and apprentice. I create form for add new lesson, by default lessons can see all, sometimes for teacher need create new lesson which can see only user role - teacher. Can I use something like checkbox "only for teacher" or other way do do this.
Thank for help.

Is there any documentation that you are following?
https://toolset.com/lesson-placement/lesson-placements-1645361-1612073/

Is there a similar example that we can see?

What is the link to your site?

#1781067
conditions.JPG

Hello,

Yes, it is possible with a custom checkbox field, for example, you can try these:
1) create a custom checkbox field "only for teacher",
2) In the post content, use [wpv-conditional] shortcode to check if current post has "only for teacher" setting and current logged-in user is a teach, then display the content, like this:

[wpv-conditional if="  ( ( '[wpv-current-user info="role"]' = 'teacher' ) AND ( $(wpcf-only-for-teacher) = '1' ) ) " ]
Here display the content
[/wpv-conditional]

See screenshot conditions.JPG

More help:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/

#1781265

Hello, thank you for answer, I'm understand how to use condition to show/hide some content, but i need made lesson 'private' (only teacher can view) by checkbox.
For example i have 10 lesson but one lesson as private - i check in checkbox "for teacher" and when guest or other user role show lesson archive they see 9 lesson, private lesson not shown.

#1781301

Unfortunately, there isn't such kind of feature within Toolset, you might consider other workaround, for example, create another post type "Teacher only lessons", use Access to setup the limitation to this post type, so other user role won't be able to access posts of post type "Teacher only lessons".

#1781305

In standard WP functionality in visibility - have "private" i'll try and it as I need hidden link but i can switch-on them through back-End may be you have case when we can friendly toolset and wp in front-end in cred form?
Thank you

#1781671

My issue is resolved now. Thank you!