I have the follwing custom post types
- event (parent)
- person (parent)
- registration (child of 2 parents)
In a loop listing the events I want to show a link to a CRED form for regitration only if:
the person is not yet registered.
I fetch the ID of the person of the logged-in user with a custom function [get_person_id]
I suppose that I need a custom function to check this condition, however, failed to establish a working one.
* Is there any documentation that you are following?
I searched the Toolset form but found only examples with a single parent-child relation.
Hello. Thank you for contacting the Toolset support.
As I understand, you just need to check if user is logged in or not, as user will be loggedin if and only if he registered. correct?
If yes:
You can try following code to display conditional content.
[wpv-conditional if="('[wpv-current-user info='id']' eq '')"]
user is NOT registered
[/wpv-conditional]
[wpv-conditional if="('[wpv-current-user info='id']' ne '')"]
user is registered
[/wpv-conditional]
Thank you for your answer, however, this is not quite my problem.
The problem is to check whether the logged in user is already registered to an event.
Conditon = there is NO record in the custom post type "registration" with
- parent 1 = the event (the condition will be placed in the view listing all events)
- parent 2 = the person associated with the logged in user = custom function [get_person_id]
Ok - that means you need to check if registration (child) post is exists for any event equal to currently logged in user. I would like to make here clear user can register for multiple events - correct? so we need to check with particular event if current user registered.
The best way is:
- create a view for your post type registration - lets say view name "display-registration-button"
- Add query filter (need to add two filters):
#) Post relationship filter = post set by parent view
#) post author = same as loggedin user
(More info: https://toolset.com/documentation/user-guides/filtering-views-query-by-author/)
- Add your registration button to this view's loop output section and save the view
- Add view "display-registration-button" in a loop listing the events