Answers.Body: <p>Once the user has submitted a post (default status unpublished) redirect the user to the Contribution page with <code>postId</code> in the URL. On the contribution page you can include a custom field (called post id) for the contribution and make it hidden via CSS or JS by default and populate the field from the URL.</p>
  <p>This will be stored against the Contribution that is created.</p>
  <p>Once the Contribution status is set to Completed you can write <a href="https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/" rel="nofollow noreferrer"><code>post()</code></a> hook and publish the content using the post id stored in contribution custom field.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2024-02-20T13:25:59.097Z
Answers.LastActivityDate: 2024-02-20T22:30:32.893Z
Answers.LastEditDate: 2024-02-20T22:30:32.893Z
Answers.UserDisplayName: Pradeep Nayak
Body: <p>I'm not sure if this is feasible, but I would like to create a payment form and associate it with a WordPress post. In short, users can create posts that will only be published after payment. So what I need is:</p>
  <ul>
  <li>Associate a post ID with the contribution form, considering that the same form would be used for different posts and users.</li>
  <li>Trigger a hook when the payment is approved.</li>
  </ul>
  
Tags: <wordpress><contribution-page>
Title: Contribution Page: associate a contribution to a WordPress post
ThreadText: # Contribution Page: associate a contribution to a WordPress post
  
  (Asked by: username_0 on 2024-02-20)
  
  I'm not sure if this is feasible, but I would like to create a payment form and associate it with a WordPress post. In short, users can create posts that will only be published after payment. So what I need is:
  
  * Associate a post ID with the contribution form, considering that the same form would be used for different posts and users.
  * Trigger a hook when the payment is approved.
  
  **Tags:** wordpress, contribution-page
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2024-02-20. Score: 2
  
  Once the user has submitted a post (default status unpublished) redirect the user to the Contribution page with `postId` in the URL. On the contribution page you can include a custom field (called post id) for the contribution and make it hidden via CSS or JS by default and populate the field from the URL.
  
  This will be stored against the Contribution that is created.
  
  Once the Contribution status is set to Completed you can write [`post()`](https://docs.civicrm.org/dev/en/latest/hooks/hook_civicrm_post/) hook and publish the content using the post id stored in contribution custom field.
  
  
  ---
  
  