public static function send_unregistered_address_notification($address)
 {
     if (!empty($address)) {
         $assigned_agent_id = DispletRetsIdxAgentsController::get_new_duty_agent_id(false, false);
         new DispletRetsIdxEmail('address_captured', array('agent_id' => $assigned_agent_id, 'property_address' => trim($address)));
     }
 }
 public static function send_agents_to_api()
 {
     $users = DispletRetsIdxAgentsModel::get_users(true);
     if (!empty($users) && is_array($users)) {
         foreach ($users as $user) {
             DispletRetsIdxAgentsController::send_agent_to_api($user->ID);
         }
     }
 }
 public static function create_new_re_search_user($args)
 {
     $args = wp_parse_args($args, array('email' => '', 'name' => '', 'phone' => '', 'realtor' => '', 'url' => '', 'upstream_url' => '', 'last_hash' => '', 'listing_agent_email' => '', 'user_address' => '', 'user_address_time' => '', 'user_registered' => '', 'send_emails' => true, 'login_user' => true, 'use_cron' => true));
     extract($args);
     if (!empty($email)) {
         $password = wp_generate_password(12, false);
         $user_id = wp_insert_user(array('user_login' => $email, 'user_email' => $email, 'user_pass' => $password, 'role' => 'displet_user'));
         if (is_wp_error($user_id)) {
             if (is_multisite() && $user_id->get_error_code() == 'existing_user_login') {
                 $user = get_user_by('email', $email);
                 if (!empty($user)) {
                     $site = get_current_site();
                     $blogs = get_blogs_of_user($user->ID);
                     if (!DispletRetsIdxUtilities::in_array_of_objects($site->id, $blogs, 'userblog_id')) {
                         $success = add_user_to_blog($site->id, $user->ID, 'displet_user');
                         if (!empty($success) && !is_wp_error($success)) {
                             $user_id = $user->ID;
                             $user_info = get_userdata($user_id);
                             if ($login_user) {
                                 wp_set_auth_cookie($user_id);
                             }
                         }
                     }
                 }
             }
             if (is_wp_error($user_id)) {
                 return $user_id->get_error_message();
             }
         } else {
             $user_info = get_userdata($user_id);
             if ($login_user) {
                 $creds = array('user_login' => $user_info->user_login, 'user_password' => $password, 'remember' => true);
                 $user = wp_signon($creds, false);
             }
         }
         $names = DispletRetsIdxUsersModel::get_first_and_last_name($name);
         $update_user_args = array('ID' => $user_id, 'role' => 'displet_user', 'display_name' => ucwords($name));
         if (!empty($user_registered)) {
             $time = strtotime($user_registered);
             if (!empty($time)) {
                 $update_user_args['user_registered'] = get_gmt_from_date(date_i18n('Y-m-d H:i:s', $time));
             }
         }
         wp_update_user($update_user_args);
         $assigned_agent_id = DispletRetsIdxAgentsController::get_new_duty_agent_id($listing_agent_email);
         $assigned_lender_id = DispletRetsIdxLendersController::get_new_duty_lender_id();
         if ($send_emails) {
             DispletRetsIdxEmailController::send_new_user_registration($email, $name, $phone, $realtor, $url, $user_info->user_login, $password, $assigned_agent_id, $assigned_lender_id);
         }
         $user_details = array('assigned_agent_id' => $assigned_agent_id, 'assigned_lender_id' => $assigned_lender_id, 'email' => $email, 'first_name' => $names['first_name'], 'last_hash' => $last_hash, 'last_name' => $names['last_name'], 'name' => $name, 'phone' => $phone, 'realtor' => $realtor, 'upstream_url' => $upstream_url, 'url' => $url, 'user_address' => urldecode($user_address), 'user_address_time' => $user_address_time, 'user_id' => $user_id);
         if ($use_cron) {
             wp_schedule_single_event(time(), 'displetretsidx_new_user_cron_jobs', array($user_details));
         } else {
             DispletRetsIdxLeadsController::new_user_cron_jobs($user_details);
         }
         unset($user_details['user_id']);
         unset($user_details['listing_agent_email']);
         // Specific to RAPB, would confuser users of hook
         unset($user_details['user_address']);
         // Specific to DispletHomeValue themes, avoiding confusion
         unset($user_details['user_address_time']);
         // Specific to DispletHomeValue themes, avoiding confusion
         do_action('displetretsidx_post_registration', $user_id, $user_details);
         return array('success' => true, 'user_id' => $user_id);
     }
 }