public static function new_uninstall($props = array()) { $user_id = EDD_Segment_Identity::get_uid($props['email']); // Send identity $traits = array('name' => isset($props['name']) ? $props['name'] : '', 'email' => $props['email']); do_action('edd_segment_identify', $user_id, $traits); // Send event $event_props = array('name' => 'sprout-invoices', 'time' => time(), 'email' => $props['email'], 'uninstall_code' => $props['uninstall_code'], 'uninstall_reason' => $props['uninstall_reason'], 'site_url' => $props['site_url']); do_action('edd_segment_track', $user_id, 'Free Uninstall', $event_props); }
/** * Used from an external API call to wp admin ajax to register a user * and create a new segment identity. * */ public static function maybe_free_license_registration() { if (!isset($_REQUEST['uid'])) { self::ajax_fail('No uid submitted'); } $email = $_REQUEST['uid']; if (!is_email($email)) { self::ajax_fail('uid not valid'); } $user_id = EDD_Segment_Identity::get_uid($email); // Send identity $traits = array('name' => isset($_REQUEST['name']) ? $_REQUEST['name'] : '', 'email' => $email, 'website' => isset($_REQUEST['url']) ? $_REQUEST['url'] : ''); do_action('edd_segment_identify', $user_id, $traits); // Send event $props = array('name' => isset($_REQUEST['item_name']) ? $_REQUEST['item_name'] : '', 'url' => isset($_REQUEST['url']) ? $_REQUEST['url'] : '', 'time' => time(), 'email' => $email); do_action('edd_segment_track', $user_id, 'Free Product Registration', $props); // The response sends the user's license key, // which at this moment is just a random string // that isn't yet tied to the user. $response = array('license_key' => wp_generate_password(40, false), 'uid' => $user_id); header('Content-type: application/json'); echo json_encode($response); exit; }