Skip Navigation

[Resolved] Disallow users to “sign-up” repeatedly to the same “special activity”

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to prevent my site Users from creating more than one child post for a given parent post.

Solution: Create a Form that creates new child posts. Create a View of child posts, filtered by post author, where the author is the same as the current logged-in User, and also filtered by post relationship as related items of the post where the View is shown. In the "no results found" section of the View of child posts, insert the Form to create new child posts. Now the Form is only shown to those Users who have not yet created a child post for the current parent post.

Relevant Documentation:
See the FAQ here:
https://toolset.com/documentation/post-relationships/how-to-create-custom-searches-and-relationships-for-users/

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

Our next available supporter will start replying to tickets in about 0.08 hours from now. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by alinaB 5 years ago.

Assisted by: Christian Cox.

Author
Posts
#1382411

Hello,

I have followed all the steps in order to build a membership website with Toolset. I have one important issue, related to the tutorial here: https://toolset.com/learn/create-membership-site-wordpress-using-toolset-plugins/allowing-members-sign-special-activities/.

The problem is that a user can subscribe several times to the same activity (i.e. they can create several custom posts of a certain type, which will be children of the same parent).

In my case, users are voluntaries and NGO's. NGO's have a custom post type called A, where they describe their project and there is a cred form for voluntaries to "sign-up" by creating a child post of type B (names are just for exemplification). A user X creates, by using that cred form, a B-type post, having the title "X-voluntary-name" and which whatever fields were extracted from the user profile. Up to here, no problem.

The problem appears when the same user X he logs out and re-logins, he will be able to "sign-up" again to the same project, i.e. create another child custom post type of the same parent, this time named "X-voluntary-name-1" and so on.

Question: how can I restrict this happening? I mention that one voluntary may subscribe to different projects, so it does not make sense to restrict the absolute number of custom posts he can create. I need a method for a user to be able to create exactly one children C1 of type B for a specific post P1 (of type A), and also create exactly one children C2 of type B for the specific post P2 (of type A). I do not want to let him create two children C1a and C1b of a custom post P1...

Is this achievable with Toolset?

#1382419
Screen Shot 2019-11-13 at 12.33.16 PM.png

Hi, if I understand correctly you can accomplish this with a View of the child post type, filtered by post relationship and post author. Let me explain step by step:
- Create a new View, and choose "Display all results" in the popup.
- Select the child post type in the Content Selection area.
- If you cannot find the Query Filter panel in the View editor screen, click "Screen Options" in the top right corner of the page to activate the Query Filter panel.
- Add a post relationship Query Filter and choose the relevant relationship between the parent and child post type, where the parent is set by the post where this View is shown. See the screenshot here for an example where Books are the parent and Chapters are the child.
- Add a post author Query Filter, where the post author is the current, logged-in User.
- In the Loop Editor, click Skip Wizard to bypass the loop wizard.
- In the "No results found" section, delete that text and replace it with the Form to create a new child post. You can insert that by clicking the Toolset Forms button above the editor.
- In the main wpv-loop tags, do not insert any content, or insert whatever content you would like to display when the author has already created one child post.
- In the parent post or parent post template, remove the Form to create new child posts and replace it with your new View. This basically creates a conditional that displays the Form to create new child posts only if the current User has not yet created a child of the current parent post.

Let me know if this is unclear and I can try to give more guidance.

#1382507

My issue is resolved now. Thank you very much!