Skip Navigation

[Resolved] Filtering based on logged-in user as author filter

This support ticket is created 6 years, 2 months 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 3 voices.

Last updated by Luo Yang 6 years, 2 months ago.

Assisted by: Luo Yang.

Author
Posts
#1130819

Tell us what you are trying to do? I created a Relationship Form. I created a nested view with a user view and a post view that supplies the form with context about which post it should be modifying, that's owned by the user. The page is called "Working Relationship Form". The views are called "authorship form for relationship form filter" and "display properties of current staff member."

I need to fix the filter on the authorship filter so it relates to the current user.

Is there any documentation that you are following?

https://toolset.com/documentation/user-guides/using-a-child-view-in-a-taxonomy-view-layout/

Is there a similar example that we can see?

What is the link to your site?

#1131071

How do you mean fix?
It is the default setting of that filter, it should just work like this out of the box.

The Filter is added in any Post View where you can add Query Filters, there choose "Post author is the same as the logged in user" and click save.
That's it, it should now show only posts of the current user.

If this does not work, can you let me know the steps you took?
I just tried it before writing the reply and that worked fine, I got only posts (or whatever else you put into the loop), from the current user.

#1131517

Greetings.

What I am trying to do is to filter a relationship form so it shows relationships of a custom post type owned by the currently logged in user.

I tested using your method and unsurprisingly, it doesn't immediately work. (passing it a specific ID does work as a user view, and then filtering the post view by the parent user view.) But that doesn't give me the current user's ID, only the ID I enter.

--Sam

#1131846
author-filter2.JPG

Dear Sam,

I assume we are talking about the relationship form of the document:
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/

You can setup shortcode [cred-relationship-role] with attribute "author", for example:
[cred-relationship-role role="child" author="$current"]

You can generate this shortcode within UI, using the option "Options only by the current visitor", see screenshot author-filter2

#1132093

One more question, I would like to automatically select 1 post owned by the author. I presume this calls for views, and I played around a bit, but would like your guidance.

#1132519

Yes, you can create a post view to get the specific post owned by the author, in the Views loop, display the relationship form by follow our document:
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/creating-new-connections-between-related-posts/