creating new donation (option-based) form by code #7868
-
I try to create a donation form by using my plugin. Recent update change the simple donation form to be campaign form, the meta data used to work is no longer valid. Do you know what is the meta data I needed to create a donation form and tie it to an existing campaign? update_post_meta($post_id, '_give_campaign_id', '3'); I try this line but seems not working. The situation I have now is that I still be able to create a donation form but It's not tied to an existing campaign? Would you be able to help? Thanks. Here are the meta data used to update the new donation form before major 4.0 update. update_post_meta($post_id, '_give_sequoia_form_template_settings', $form_template_settings); update_post_meta($post_id, '_give_donation_levels', $donation_levels); update_post_meta($post_id, '_give_price_option', $give_price_option); update_post_meta($post_id, '_give_levels_minimum_amount', $give_levels_min_amount); update_post_meta($post_id, '_give_levels_maximum_amount', $give_levels_max_amount); update_post_meta($post_id, '_give_display_style', $give_display_style); update_post_meta($post_id, '_give_custom_amount', $give_custom_amount); update_post_meta($post_id, '_give_custom_amount_range_maximum', $give_custom_amount_range_maximum); update_post_meta($post_id, '_give_custom_amount_range_minimum', $give_custom_amount_range_minimum); update_post_meta($post_id, '_give_custom_amount_text', $give_custom_amount_text); update_post_meta($post_id, '_give_show_register_form', 'none'); //new line update_post_meta($post_id, '_give_campaign_id', $give_campaign_id); |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hi @chenganma. Yes, with the latest Give release, every form should be associated with a campaign. In other words, form cannot exist outside the campaign context. There are a couple of approaches you could take here. The first one is to create a campaign using the campaign model. Also, the donation form will be automatically created and associated with a campaign. Example The second one is to use the REST API and send a request to this endpoint It will create a campaign and the donation form for you. If you want to associate an existing form with a campaign, that should already be covered by our migration system. If, for some reason, that didn't happen, the only way of doing that is to use Hope this helps. |
Beta Was this translation helpful? Give feedback.
-
I have a solution in place for my application/plugin thanks to your information. |
Beta Was this translation helpful? Give feedback.
Hi @chenganma. Yes, with the latest Give release, every form should be associated with a campaign. In other words, form cannot exist outside the campaign context. There are a couple of approaches you could take here. The first one is to create a campaign using the campaign model. Also, the donation form will be automatically created and associated with a campaign. Example
givewp/src/Campaigns/Controllers/CampaignRequestController.php
Line 217 in a229427
The second one is to use the REST API and send a request to this endpoint
givewp/src/Campaigns/Routes/RegisterCampaignRoutes.php
Line 208 in a…