Skip Navigation

[Resolved] Form to select team

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

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

Assisted by: Luo Yang.

Author
Posts
#1217336

Hi, I'm trying to create a site that allows users to register and then pick a fantasy football (soccer) team based on certain criteria.

My current stumbling block is creating a form that allows a registered user to pick their team.

I have Custom Post Types set up for...

Players (with a custom field for the players value)
Teams (20 teams - English Premier League)
Positons (GK, DF, MD, ST)

I have created relationships between the Player & Team and Player and Position.
I have imported all players with the CSV plugin and they display in the backend 'Players' area successfully with associated Team and position showing. They don't however appear in the related areas. For example if I go to 'GK' in the 'Position' CPT it doesn't display all GKs?

How do I now create a form where a registered user selects 11 players and submits their team? Do I need to create a separate CPT for submitted teams?!

Thanks,

John

#1217515

Dear John,

I suggest you setup two post types:
- Fantasy teams
- Players(You have already done in your website)

Setup many-to-many relationship between above two post types, for example "fantasy-team-player":
1) in step "Custom limits", in post type "Player" side, setup value 11 in option "Limit"

2) in step "Relationship fields", in the intermediate post type, add a custom select field "Positons", with options: GK, DF, MD, ST. See screenshot Positons.JPG

3) In step "Names", enable option "Intermediary Post Type visible in WordPress admin menu", then you will be able to query the "Intermediary Post Type" with Toolset Views plugin, see screenshot fantasy-team-player.JPG

When your users login into your website, redirect him to a page, display a post form for creating new "Fantasy teams" posts + below post view
A post view:
- query "Fantasy teams" posts
- Filter by post's author is current logged-in user
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/
- in the view's loop, display "Fantasy teams" post link
hidden link

User click the "Fantasy teams" post link, redirect him to single "Fantasy teams" post, here display a post view + a relationship form:
1) "fantasy-team-player" post view
- Query posts of intermediate post type "fantasy-team-player"
- filter by:
Select posts in a fantasy teams Players relationship that are related to the Post where this View is shown.
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items
- in the view's loop, display "Positons" field value + related "Player" post information
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-one-related-item-parent

Setup a relationship form to connect current user's "Fantasy teams" posts with existed "Players" posts
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/

2) relationship form:
Connect current "Fantasy teams" post with existed "Player" posts
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/

For your reference.

#1220511

Hi Luo,

Thank you very much for the reply and detailed notes. One thing so far is I can't seem to see any of the attached screenshots your mention?

Thanks, John

#1220566
fantasy-team-player.JPG
Positons.JPG

Dear John,

I have uploaded the screenshots.