{"id":3561,"date":"2020-10-23T10:49:46","date_gmt":"2020-10-23T14:49:46","guid":{"rendered":"https:\/\/rafflepress.com\/?post_type=ht_kb&#038;p=3561"},"modified":"2022-02-03T08:28:49","modified_gmt":"2022-02-03T13:28:49","slug":"complete-action-or-add-user-programmatically","status":"publish","type":"ht_kb","link":"https:\/\/rafflepress.com\/docs\/complete-action-or-add-user-programmatically\/","title":{"rendered":"Complete Action or Add User Programmatically"},"content":{"rendered":"<p>NOTE: This document is intended for developers.<\/p>\n<p>RafflePress has an <a href=\"https:\/\/rafflepress.com\/docs\/invent-your-own\/\">Invent Your Own<\/a> action which lets you create custom actions that RafflePress does not have out of the box. This guide will show you how to programmatically complete these actions.<\/p>\n<p>In this example, we will create a custom action that users get entires in exchange for completing a survey form.<\/p>\n<ol>\n<li>Create the action in RafflePress<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3564\" src=\"https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-on-2020-10-23-at-10-28-40.png\" alt=\"\" width=\"985\" height=\"816\" srcset=\"https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-on-2020-10-23-at-10-28-40.png 985w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-on-2020-10-23-at-10-28-40-300x249.png 300w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-on-2020-10-23-at-10-28-40-768x636.png 768w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Screen-Shot-on-2020-10-23-at-10-28-40-50x41.png 50w\" sizes=\"auto, (max-width: 985px) 100vw, 985px\" \/><br \/>\nNote: If you need to hide the action from the user you can get the class id of the action and add custom css to hide. Example: .rafflepress-action-9chrxc{display:none}<\/li>\n<li>Next, get the giveaway id which can be found in the URL while viewing the giveaway in the admin area.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-3565 size-full\" src=\"https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-32-15.png\" alt=\"\" width=\"974\" height=\"514\" srcset=\"https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-32-15.png 974w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-32-15-300x158.png 300w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-32-15-768x405.png 768w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-32-15-50x26.png 50w\" sizes=\"auto, (max-width: 974px) 100vw, 974px\" \/><\/li>\n<li>Next, get the action id which you can get in the URL while editing the action.<br \/>\n<img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-3566\" src=\"https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-45-45.png\" alt=\"\" width=\"1087\" height=\"446\" srcset=\"https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-45-45.png 1087w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-45-45-300x123.png 300w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-45-45-1024x420.png 1024w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-45-45-768x315.png 768w, https:\/\/rafflepress.com\/wp-content\/uploads\/2020\/10\/Annotation-on-2020-10-23-at-10-45-45-50x21.png 50w\" sizes=\"auto, (max-width: 1087px) 100vw, 1087px\" \/><\/li>\n<li>Finally, review the code in this sample plugin below available in our GitHub repository.<br \/>\n<a href=\"https:\/\/gist.github.com\/seedprod\/b8abe1d0076c4281e6e19a679baacaae\">https:\/\/gist.github.com\/seedprod\/b8abe1d0076c4281e6e19a679baacaae<\/a>This plugin requires the <strong>giveaway_id<\/strong>, <strong>action_id<\/strong>, and <strong>email <\/strong>parameters. It contains two code samples: one adds a user, and the other programmatically complete an entry.<\/p>\n<p>With this plugin active, we would call this action when the Survey is completed to programmatically complete the entry.<\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>NOTE: This document is intended for developers. RafflePress has an Invent Your Own action which lets you create custom actions that RafflePress does not have out of the box. This guide will show you how to programmatically complete these actions. In this example, we will create a custom action that users get entires in exchange [&hellip;]<\/p>\n","protected":false},"author":1,"comment_status":"open","ping_status":"closed","template":"","format":"standard","meta":{"limit_modified_date":"","last_modified_date":"","_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"ht-kb-category":[6],"ht-kb-tag":[],"class_list":["post-3561","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-integrations"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/ht-kb\/3561","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/comments?post=3561"}],"version-history":[{"count":3,"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/ht-kb\/3561\/revisions"}],"predecessor-version":[{"id":7544,"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/ht-kb\/3561\/revisions\/7544"}],"wp:attachment":[{"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/media?parent=3561"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/ht-kb-category?post=3561"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/rafflepress.com\/wp-json\/wp\/v2\/ht-kb-tag?post=3561"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}