Skip Navigation

[Resolved] Display child posts on parent post only if logged-in user is parent's author

This support ticket is created 5 years 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 5 years ago.

Assisted by: Nigel.

Author
Posts
#1384157

Hello,

I am trying to use Views in order to display a section that consists of child posts of the currently displayed post, but I want this section to be visible only if the current logged-in user is the author of the currently displayed parent post. I have tried several approaches, but none of them works. The main drawback is that a user can now see the child posts of a parent of the same type that was created by another user, and this is forbidden in my project.

Example: users: NGO's (create parents - Projects), Volunteers (create children - Signups). I want that an NGO sees only volunteers that have signed-up for their own projects (which I have already achieved without any problem), but in the same time I do not want that NGO X sees the volunteers signed-up for a project authored by NGO Y.

Thank you in advance!

#1384345

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Alina

You can use conditional shortcodes to check if the current user is the author of the current post.

So if you have a template for the parent posts where you insert the View of the child posts, you could wrap the shortcode that inserts the child View with the following conditional shortcode:

[wpv-conditional if="( '[wpv-post-author format='meta' meta='ID']' eq '[wpv-user field='ID']' )"]
...only if current user is the post author display this...
[/wpv-conditional]