Skip Navigation

[Resolved] Filter relationship form child posts

This support ticket is created 3 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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: Africa/Casablanca (GMT+00:00)

This topic contains 3 replies, has 3 voices.

Last updated by Nigel 2 years, 3 months ago.

Assisted by: Jamal.

Author
Posts
#1988727

I need a filter to apply to the [cred-relationship-role role='child'] shortcode.

In short, the [cred-relationship-role role='child'] by default shows all posts available, we can set in the GUI to filter it by author. But, what I need is a hook to filter that list (select2) even further (by a complex custom logic)

What filter should I use for this? I scanned the code and could not find any filter applied to that query, which is restrictive. I thought of using CRED_Potential_Association_Query_Filter_Posts_Author_For_Association_Role (the author filter is defined in there), but it seems the filter only allows to filter by Author ID, which is not what I want.

I need the [cred-relationship-role role='child'] to show only posts defined by my custom logic.

If there is no such filter, what would be the next best solution to have a relationship form select2 show only those posts I want to show?

#1993613

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+00:00)

Hello Beda,

Our 2nd Tier has escalated this as a feature request to the developers. And the devs have added it to a dev board. Unfortunately, we don't have a filter or a solution to share with you. Using a generic field remains the available solution.

All the best.

#1993633

OK thanks for the heads up Jamal, sad but not much we can do about.

I wanted to share the solution I use here (not a generic field as I think AJAX Populating select2 or other select fields is too expensive given it will rely on WordPress AJAX which is generally not the fastest), and I simply am not that conformable with JS as I am with PHP, but the code is a bit too long and also part of a bigger class, so taking it all apart to share here's a bit too much 😛

However if anyone is interested in the solution please feel free to either ask me here or over at my profile/website, I am happy to help.

Cheers, and I hope we will see such feature sometime in the future!

#2269257

Nigel
Supporter

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

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

I revisited this question for another client and shared a solution here: https://toolset.com/forums/topic/filter-post-in-form-relationship/

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.