Skip to content
This repository was archived by the owner on May 6, 2021. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions lib/class-sendgrid-nlvx.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
}