Skip Navigation

[Gelöst] Relationship between a WordPress User and a Custom Post Type „Member“

Dieser Thread wurde gelöst. Hier ist eine Beschreibung des Problems und der Lösung.

Problem: I would like to know how to create relationships between a WordPress User and a Custom Post Type post created by Types.

Solution:
I can think of 3 ways to link a User and a CPT post.
1. Make the User the author of the post.
2. Use a custom field to store a reference to the related item. For example, you can create a custom field on the CPT Member post that holds the related WordPress User's ID. Or you can create a custom field on the WordPress User profile that holds the matching Member's post ID.
3. Use a custom taxonomy that includes a term for each User, and apply that term to each related post.

Each option has its own pros and cons, so it often depends on your site requirements. I think #2 is usually the most practical.

This support ticket is created vor 6 Jahren, 8 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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)

Dieses Thema enthält 6 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von alberto vor 6 Jahren, 8 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#623049
db-gym-fin-2018-03-07.png

We don´t know how to relate the wordpress user registration to a Custom Post type Member so we can relate this member to other CPT , see image attached the wp-user box and the Member CPT, this is what we would like to do.

link to site versteckter Link

#623075

Hi, there are several ways to link a WordPress User to a post.
1. Make the User the author of the post.
2. Use a custom field to store a reference to the related item. For example, you can create a custom field on the CPT Member post that holds the related WordPress User's ID. Or you can create a custom field on the WordPress User profile that holds the matching Member's post ID.
3. Use a custom taxonomy that includes a term for each User, and apply that term to each related post.

Each option has its own pros and cons, so it often depends on your site requirements. I think #2 is usually the most practical.

#624769

I used woocommerce for the user login and then a shortcode to pass the user ID to the member table CPT, so I can use all the frontend account pages from woocommerce , could you give me a hint if I would have problems in the future using this strategy ?

#624915

...and then a shortcode to pass the user ID to the member table CPT
I don't understand what this means, could you be more specific about this?

#624924

Yes, thank you for asking:

1. I use the woocommerce form to create a user
account,

2. Then I use a second form made with CRED for a CPT
called member account

Then the steps are:

--> The site managers goes and creates a new user
account (email, first name, password) through the
woocommerce default my-account form,

--> Then in the CRED form (member CPT) one of the
custom fields is "user ID"

--> for this field I used a view shortcode to auto
populate the field

[wpv-current-user info="ID"]

When the manager wants to add a new member he needs to
log out and fill up the user woocommerce form first,
create the user, and then go to the second form
(CRED, Member CPT) and the user ID wordpress, will
auto populate in the member CPT.
Then I can relate all the other tables with this
current-user info="ID" from the member CPT .
I wonder if this strategy is one way to do it or will
give me problems that I can´t see now, thanks a lot
for your reply.

#625009

When the manager wants to add a new member he needs to
log out and fill up the user woocommerce form first,
create the user, and then go to the second form...

The manager must be logged in as the new User before submitting the second form. Otherwise, the new Member will not be linked to the correct User. I'm not sure how your User form works, but it may or may not automatically log in the new User account. Other than that, sounds okay to me.

#625117

thanls a lot for your quick support!!