Support

Account

Home Forums Backend Issues (wp-admin) Mapping user to post type

Helping

Mapping user to post type

  • Hello everyone!

    I am trying to build a social market place where each user has their own profile page. i would like users to be able to post products on their own page (im using woocommerce for that and its working fine for now) but also

      i want users to be able to visit each other’s pages and view each others products

    .

    Now thats were i am lost (i am not a developer but im trying my best to work with code and web dev concepts). At first I created a custom post type, added custom fields using ACF, and through using elementor theme builder, i created a loop to list all the members and singles to act as profile pages. however since i created post types not users i couldn’t set the login up. (how can a post type log in?)

    to fix this i created user login and registration, however i was not able to map the user to the respective post. Any ideas on how to solve this? perhaps even a completely different approach?

  • To associate the a post with a user you would need to have either a user field type on the post of a post object field on the user, or both and code them to be bidirectional.

    However you set this up you’d need to have an acf/save_post filter that creates the relationship when a new user is added. Basically, something along the lines of when a new user is added a new post is automatically created for that user and this post is automatically added to the post object field for the user.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.