admin管理员组

文章数量:1126967

I’ve created a Custom Post Type Name 'Campaigns' and now, I would like the users of my site (only registered ones) to indicate their interest in promoting the campaign by just clicking the promote on each campaign single page. On the campaign page, they would just click on "Promote" button and they would be associated with the camp (no need for tickets, payment, …). I have no clue on where to look at to implement that (taxonomies, meta, …, ?) and how this will be stored (on user entity, on event custom post type entity)? I need help!

I’ve created a Custom Post Type Name 'Campaigns' and now, I would like the users of my site (only registered ones) to indicate their interest in promoting the campaign by just clicking the promote on each campaign single page. On the campaign page, they would just click on "Promote" button and they would be associated with the camp (no need for tickets, payment, …). I have no clue on where to look at to implement that (taxonomies, meta, …, ?) and how this will be stored (on user entity, on event custom post type entity)? I need help!

Share Improve this question edited Jan 17, 2024 at 8:03 bueltge 17.1k7 gold badges61 silver badges97 bronze badges asked Jan 16, 2024 at 12:20 Joshua EhimareJoshua Ehimare 11 bronze badge 1
  • note that there may not be a single correct answer for this, and you need to be able to mark a single answer as the official canonically correct answer, not just the most useful response – Tom J Nowell Commented Jan 16, 2024 at 13:17
Add a comment  | 

1 Answer 1

Reset to default 0

You can use the update_user_meta function in WordPress to store information about the user's interest in promoting a campaign

// Assuming $user_id is the current user's ID and $campaign_id is the ID of the campaign.

update_user_meta($user_id, 'promoted_campaigns', $campaign_id, true);

本文标签: How to Connect my Users to a custom post type I Labelled Campaign