Tell us what you are trying to do?
I have a form for users to submit product returns. I want the user to choose the product they will return from products they have registered. I built a CPT and Form for Product Registration. I used a relationship to connect the Product Registration to the CPT/Form for Returns.
It looks good, but, I need the user to only choose products they have registered. So, in short, how do I filter a relationship in a front end form, by the post author? I have thought through a few different things, like a view for instance, but I'm not sure I can filter a cred field, and a relationship field at that.
Is there any documentation that you are following?
Haven't found anything dealing with this.
Hello,
Please elaborate the questions with detail steps:
How do you setup the post types and relationships?
How do you setup the "Product Registration"?
Where and how do you want to setup the relationship filter?
I need to test it in my localhost, thanks
I've added some images.
How do you setup the post types and relationships?
I made a custom post type for "Product Registration" and a custom post type for "Returns"...
I made a one-to-one relationship for "Product Registration" and "Returns" (see relationship.JPG)...
I made a Post Form for "Product Registration" and a Post Form for "Returns".
Scenario:
Customer X uses "Product Registration" Post Form on the front end to Register Products they own.
Customer X uses "Return" Post Form on the front end to Return Products they have Registered.
When Customer X is using the "Return" Post Form (see formfrontend.JPG) they are prompted to choose a post from the "Product Registration" relationship field.
Where and how do you want to setup the relationship filter?
Customer X should ONLY be able to select a post from the "Product Registration" relationship field that they created using the "Product Registration" Post Form.
The ISSUE is that they can choose "Product Registration" posts created by any user, ie Customer A, Customer B, etc.
In the "Return" Post Form I need to filter the relationship by Post Author. This way Customer X can only choose "Product Registration" posts created by Customer X.
It is possible within Toolset form, for example, you can try these:
Edit the "Return" Post Form, find and edit the "Product Registration" relationship field, there is an option, enable option "Get only options by the current author", see screenshot: author-filter.JPG
If you are using expert mode, you can add attribute author='$current' to form shortcode, for example:
[cred_field ... author='$current']
More help:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
author Optional. Use it with a parent selector field to specify that the list of parent posts should be limited to those authored by the mentioned user ID.
Brilliant, can't believe I didn't think to check there! Thank you.