Skip to content

Instantly share code, notes, and snippets.

@ericnicolaas
Created November 3, 2021 06:31
Show Gist options
  • Save ericnicolaas/777d65aa41332ea2fb7df8b011e39a57 to your computer and use it in GitHub Desktop.
Save ericnicolaas/777d65aa41332ea2fb7df8b011e39a57 to your computer and use it in GitHub Desktop.
Create a new campaign programatically
add_action(
'admin_init',
function() {
return charitable_create_campaign(
array(
'title' => 'My new campaign',
'content' => 'Extended content about this campaign',
'creator' => get_current_user_id(),
'status' => 'draft',
'parent' => 541,
'description' => 'Programatically created campaign',
'goal' => 5000,
'end_date' => date( 'Y-m-d', strtotime( '+1 year' ) ),
'suggested_donations' => array(
array( 'amount' => 25, 'description' => 'Bronze' ),
array( 'amount' => 75, 'description' => 'Silver' ),
array( 'amount' => 150, 'description' => 'Gold' ),
),
'allow_custom_donations' => 1,
)
);
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment