diff --git a/lib/class-sendgrid-nlvx.php b/lib/class-sendgrid-nlvx.php index 8d99f7d..0605a1a 100644 --- a/lib/class-sendgrid-nlvx.php +++ b/lib/class-sendgrid-nlvx.php @@ -79,10 +79,11 @@ public static function get_all_lists() * @param string $email The email of the recipient * @param string $first_name The first name of the recipient * @param string $last_name The last name of the recipient + * @param array $custom_fields Custom field data * * @return mixed The recipient ID if successful, false otherwise. */ - public static function add_recipient($email, $first_name = '', $last_name = '') + public static function add_recipient($email, $first_name = '', $last_name = '', array $custom_fields = array()) { $auth = Sendgrid_NLVX::get_auth_header_value(); @@ -108,6 +109,10 @@ public static function add_recipient($email, $first_name = '', $last_name = '') if ( '' != $last_name ) { $contact['last_name'] = $last_name; } + + foreach ( $custom_fields as $field => $value ) { + $contact[$field] = $value; + } $req_body = json_encode(array($contact)); $args['body'] = $req_body; @@ -191,4 +196,4 @@ public static function create_and_add_recipient_to_list($email, $first_name = '' return Sendgrid_NLVX::add_recipient_to_list($recipient_id, $list_id); } -} \ No newline at end of file +}