Guest User

Mailster, Formidable integration

a guest
Nov 15th, 2020
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. add_action('frm_after_create_entry', 'mailster_formidable_subscribe', 30, 2);
  2. add_action('frm_after_update_entry', 'mailster_formidable_subscribe', 30, 2);
  3.  
  4. function mailster_formidable_subscribe($entry_id, $form_id){
  5. if ( $form_id == 55 ) { //change 55 to the ID of your form
  6.  
  7. // define to overwrite existing users
  8. $overwrite = true;
  9.  
  10. // add with double opt in
  11. $double_opt_in = false;
  12.  
  13. // prepare the userdata from a $_POST request. only the email is required
  14. $userdata = array(
  15. 'email' => $_POST['item_meta'][535], //change 535, 534, 533 to the ID of your email, first name and last name field
  16. 'firstname' => $_POST['item_meta'][533],
  17. 'lastname' => $_POST['item_meta'][534],
  18. 'status' => $double_opt_in ? 0 : 1,
  19. );
  20. $subscriber_id = mailster( 'subscribers' )->add( $userdata, $overwrite );
  21.  
  22. if ( ! is_wp_error( $subscriber_id ) ) {
  23.  
  24. // your list ids
  25. $list_ids = 1;
  26. mailster( 'subscribers' )->assign_lists( $subscriber_id, $list_ids );
  27.  
  28. } else {
  29. // actions if adding fails. $subscriber_id is a WP_Error object
  30. }
  31. }
  32. }
RAW Paste Data