Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_action('frm_after_create_entry', 'mailster_formidable_subscribe', 30, 2);
- add_action('frm_after_update_entry', 'mailster_formidable_subscribe', 30, 2);
- function mailster_formidable_subscribe($entry_id, $form_id){
- if ( $form_id == 55 ) { //change 55 to the ID of your form
- // define to overwrite existing users
- $overwrite = true;
- // add with double opt in
- $double_opt_in = false;
- // prepare the userdata from a $_POST request. only the email is required
- $userdata = array(
- 'email' => $_POST['item_meta'][535], //change 535, 534, 533 to the ID of your email, first name and last name field
- 'firstname' => $_POST['item_meta'][533],
- 'lastname' => $_POST['item_meta'][534],
- 'status' => $double_opt_in ? 0 : 1,
- );
- $subscriber_id = mailster( 'subscribers' )->add( $userdata, $overwrite );
- if ( ! is_wp_error( $subscriber_id ) ) {
- // your list ids
- $list_ids = 1;
- mailster( 'subscribers' )->assign_lists( $subscriber_id, $list_ids );
- } else {
- // actions if adding fails. $subscriber_id is a WP_Error object
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement