Skip Navigation

[Resolved] Assign (other) User as parent of custom post

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

Problem: How to "assign" uploaded content to site users so that only they can view it.

Solution: The most straightforward assignment is by making the users the post authors of the content.

Then create a View to display posts of the currently logged in user, which means that other users will not see the content.

Relevant Documentation: https://toolset.com/documentation/user-guides/filtering-views-query-by-author/

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.

This topic contains 2 replies, has 2 voices.

Last updated by gaborG 5 years, 4 months ago.

Assigned support staff: Nigel.

Author
Posts
#401756

If I want to upload content for my users to my website, is it possible to assign a user as a parent of a content? If yes, how?
If it's not possible, how do you suggest I could solve this matter? I want to upload content and assign it to a particular user, so that only they can view it, others can't. If I would create a "Customer" custom post type, I could assign content to them that way, but can I automatically create a Customer with user-data when a user registers?

#401925

Nigel
Supporter

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

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

It rather depends upon who is doing the assigning and when it happens, but basically there are two routes you can go down.

- You can have users registered on your site and then simply assign them to be the post authors of the content. Where are they going to see their content? You can have a "my content" page with a view to display the posts of the currently logged in user, for example.

If you don't want to make the user the post author for some reason, then you can add a custom post field to your content to store the user id, and you will be able to filter your output based upon that field.

- Alternatively, you can, as you say, create a CPT for your users, and have that post be the parent of your content posts. You would then still need to link your users to your user CPT (via authorship or via a custom field), and then create a filter for displaying the content only if the parent post was the same as the logged in user.

As you might surmise from my description, the second route involves an extra intermediary which I'm not sure you need.

Also, when you want to limit who can see the content, I've worked on the assumption you will have something like a "my content" page, but if you want to simply hide content that should not be seen in your normal views, then you will want to add Access into the mix.

Let me know if you can proceed on that basis or if you need any clarification.

#402031

Thank you for elaborating the options.
I'll go with the first option. 🙂 Thanks.