Sailthru_Client::saveUser PHP Method

saveUser() public method

Save existing user
public saveUser ( String $id, array $options = [] ) : array
$id String
$options array
return array
    public function saveUser($id, array $options = [])
    {
        $data = $options;
        $data['id'] = $id;
        return $this->apiPost('user', $data);
    }

Usage Example

Ejemplo n.º 1
0
        if (!empty($_POST['sailthru_email_list'])) {
            $lists = explode(',', $_POST['sailthru_email_list']);
            foreach ($lists as $key => $list) {
                $subscribe_to_lists[$list] = 1;
            }
            $options['lists'] = $subscribe_to_lists;
        } else {
            $options['lists'] = array('Sailthru Subscribe Widget' => 1);
            // subscriber is an orphan
        }
        $options['vars']['source'] = get_bloginfo('url');
        $return['data'] = array('email' => $email, 'options' => $options);
        if ($return['error'] == false) {
            $sailthru = get_option('sailthru_setup_options');
            $api_key = $sailthru['sailthru_api_key'];
            $api_secret = $sailthru['sailthru_api_secret'];
            $client = new Sailthru_Client($api_key, $api_secret);
            $res = $client->saveUser($email, $options);
            if ($res['ok'] != true) {
                $result['error'] = true;
                $result['message'] = "There was an error subscribing you. Please try again later.";
            }
            $return['result'] = $res;
        }
        break;
    default:
        $return['error'] = true;
        $return['message'] = 'No action defined. None taken.';
}
echo json_encode($return);
die;
All Usage Examples Of Sailthru_Client::saveUser