Skip Navigation

[Resolved] Restrict author to his own child posts and redirect on author login

This support ticket is created 5 years, 11 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 10 replies, has 2 voices.

Last updated by Luo Yang 5 years, 11 months ago.

Assisted by: Luo Yang.

Author
Posts
#1200276

Hi,
I am looking to create login redirect for authors so that they land on a page that displays their child posts and where they can't view the author's child posts.
I have created a child view with post relationship query filter. I created a parent view with author is current logged in user query filter and inserted the child view into the parent view. The results show up fine per parent, but when I log in as an author, I am able to see other author's child posts. I need help locking the author to his own posts and then redirecting him on login to view his own supporters. I have checked Access and the settings seem right. Not sure what I'm missing here.

thanks in advance!

#1200315

Hello,

Q1) login redirect for authors
It needs custom codes, for example:
You can try WordPress built-in filter hook "login_redirect"
https://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect

When user login into your website, check current user's role, then redirect him to a specific page, for example
https://wordpress.stackexchange.com/questions/188308/after-login-that-will-redirect-user-role-into-a-page

Q2) I need help locking the author to his own posts
I assume you want display child posts which author is current logged in users.

Same as parent post view, you just need to add a author filter into the child post view, and test again:
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/

#1200327

yea, no luck. I actually tired all variations for author filter.

Parent view:
Select posts with the author the same as the current logged in user.

Child view:
Select posts with the author set by the parent User View.

#1200328

I have Author login redirect working. But the view loads no results with above configuration. With previous configuration, author is able to view other's child posts.

#1200332

There is a misunderstand:
1) In the parent post view, you just need one filter:
Post author is the same as the logged in user

In the loop section, display below child post view

2) In the child post view, you need setup two filters:
- filter by post type relationship
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
- Post author is the same as the logged in user
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/#post-author-is-the-same-as-the-logged-in-user

#1200343

Yea. It's not working. That's why I tried "Select posts with the author set by the parent User View."
In fact, it doesn't matter which author filter I use, it shows not items found. They only way the child posts are shown is if I remove author filter from child. Here's video hidden link

#1200344

Also, I have custom role but its a copy of the default author role

#1200348

Please provide your website credentials in below private message box, also point out the problem page URL and view URLs, I can check it in a live website, thanks

#1200371

Thanks for the details, I can login into your website, here are what I found:

1) please check "support" post list: Dashboard-> Supporters
hidden link

The first item: larry, in "author" column, it is empty, so it conduct the problem as you mentioned above, you can edit it:
hidden link
setup the post author as the specific user "evaanditest", and save the post

2) Edit the child post view: My Supporters 2
hidden link

a) in section "Query Filter" you are using filter by URL parameters, but in your case, it should be filter by parent view, like this:
Select posts in a Partner Supporters relationship that are a related to the current post in the loop.

b) and you will need to add the author filter:
Post author is the same as the logged in user

And test again, I have left them unchanged, please let me know if you need assistance to make those changes.

#1200378

So it's a requirement that the child be assigned an author?

#1200379

No, It is not required, if you don't want to setup "Supporters" post's author, then you don't need to setup the author filters in child post view "My Supporters 2", just need to setup the filter as:
Select posts in a Partner Supporters relationship that are a related to the current post in the loop.

See my answer above:
https://toolset.com/forums/topic/restrict-author-to-his-own-child-posts-and-redirect-on-author-login/#post-1200371
a) in section "Query Filter" ...