/** * @return: print: text */ function displetretsidx_save_search_registration_user_phone_value() { $user = DispletRetsIdxLeadsModel::get_current_user_data(); if (!empty($user['phone'])) { echo $user['phone']; } }
private static function _save_search($args) { extract($args); if (!empty($user) && !empty($hash)) { if (!user_can($user->ID, self::$_capabilities['save_search']) || user_can($user->ID, self::$_capabilities['view_leads'])) { return 'User does not have the capability to save searches.'; } if (empty($name_exists)) { $saved_searches = !empty($user->{self::$_meta_keys['lead']['saved_searches']}) ? $user->{self::$_meta_keys['lead']['saved_searches']} : array(); $this_search = array('hash' => $hash, 'name' => $search_name); if (!empty($user->{self::$_meta_keys['api_user_id']})) { $saved_search_criteria = DispletRetsIdxResidentialsModel::get_search_criteria_from_hash($hash); $saved_search_id = DispletRetsIdxUsersApiController::create_saved_search($user->{self::$_meta_keys['api_user_id']}, $search_name, $saved_search_criteria); if (isset($saved_search_id)) { $this_search['api_id'] = $saved_search_id; } } $saved_searches[] = $this_search; update_user_meta($user->ID, self::$_meta_keys['lead']['saved_searches'], $saved_searches); new DispletRetsIdxEmail('saved_search', array('agent_id' => DispletRetsIdxLeadsModel::get_assigned_agent_id($user->ID), 'lender_id' => DispletRetsIdxLeadsModel::get_assigned_lender_id($user->ID), 'search_url' => trailingslashit(get_permalink(self::$_options['search_results_page_id'])) . $hash, 'user_email' => $user->user_email, 'user_name' => $user->display_name, 'user_phone' => $user->{self::$_meta_keys['lead']['phone']})); do_action('displetretsidx_post_lead_saved_search', $user->ID, $this_search); return 'Saved Search'; } } }
public static function send_saved_property_to_api($user_id, $saved_property, $api_user_id = false) { if (!empty($user_id) && !empty($saved_property)) { if (empty($api_user_id)) { $api_user_id = DispletRetsIdxLeadsModel::get_api_user_id($user_id); } if (!empty($api_user_id)) { return DispletRetsIdxUsersApiController::create_saved_property($api_user_id, $saved_property['sysid'], $saved_property['type'], $saved_property['rating'], $saved_property['message']); } } }
private static function _enqueu_intercom_io_js_for_agent_and_search_users() { if (is_user_logged_in() && current_user_can('displet_view_leads')) { self::enqueue_js('intercom-io-script.js'); $user = wp_get_current_user(); $intercom_vars = array('app_id' => 'lb5nppo2', 'created_at' => current_time('timestamp'), 'domain' => home_url(), 'email' => $user->user_email, 'name' => $user->display_name, 'plugin_version' => self::$_version, 'user_hash' => hash_hmac('sha256', $user->user_email, 'k3vZZS7gjJ1p3DIZvbwvC303_TXqLSYWlFwhhS43'), 'wp_version' => get_bloginfo('version')); $user_leads = DispletRetsIdxLeadsModel::get_users_count($user->ID); if (!empty($user_leads)) { $intercom_vars['user_leads'] = $user_leads; } self::localize_js('intercom-io-script.js', 'intercomSettings', $intercom_vars); } }
private static function _new($user_id, $args) { extract(wp_parse_args($args, array('address' => '', 'appointment1' => '', 'appointment2' => '', 'city' => '', 'email' => '', 'message' => '', 'mls_number' => '', 'name' => '', 'phone' => '', 'state' => '', 'url' => '', 'zip' => ''))); $assigned_agent_id = DispletRetsIdxLeadsModel::get_assigned_agent_id($user_id); $assigned_lender_id = DispletRetsIdxLeadsModel::get_assigned_lender_id($user_id); $comma_separated_address_components = array_filter(array($address, $city, $state), 'trim'); $address = !empty($comma_separated_address_components) ? implode(', ', $comma_separated_address_components) : ''; if (!empty($zip)) { $address .= ' ' . trim($zip); } new DispletRetsIdxEmail('showing_request', array('agent_id' => $assigned_agent_id, 'lender_id' => $assigned_lender_id, 'property_address' => trim($address), 'property_mls' => $mls_number, 'property_url' => $url, 'user_appointment' => $appointment1, 'user_appointment2' => $appointment2, 'user_email' => $email, 'user_message' => $message, 'user_name' => $name, 'user_phone' => $phone)); $inquiry_details = array('email' => $email, 'name' => $name, 'phone' => $phone, 'address' => $address, 'first_appointment' => $appointment1, 'second_appointment' => $appointment2, 'message' => $message); DispletRetsIdxPropertyInquiriesController::update_property_inquiries($user_id, $inquiry_details); DispletRetsIdxUsersController::send_to_zapier($inquiry_details, 'showing'); }
public static function send_email_to_friend_request() { check_ajax_referer('displet_email_friend_nonce'); if (isset($_POST['action']) && $_POST['action'] == 'displet_email_friend_request') { if (!empty($_POST['email']) && is_email($_POST['email'])) { $user = wp_get_current_user(); $assigned_agent_id = !empty($user->ID) ? DispletRetsIdxLeadsModel::get_assigned_agent_id($user->ID) : false; $assigned_lender_id = !empty($user->ID) ? DispletRetsIdxLeadsModel::get_assigned_lender_id($user->ID) : false; $user_name = !empty($user->display_name) ? $user->display_name : 'A Friend'; $user_email = !empty($user->user_email) ? $user->user_email : false; $address = trim($_POST['address']) . ', ' . trim($_POST['city']) . ', ' . trim($_POST['state']) . ' ' . trim($_POST['zip']); new DispletRetsIdxEmail('emailed_friend', array('agent_id' => $assigned_agent_id, 'friend_email' => $_POST['email'], 'friend_name' => $_POST['name'], 'lender_id' => $assigned_lender_id, 'property_address' => $address, 'property_url' => $_POST['url'], 'user_email' => $user_email, 'user_message' => $_POST['message'], 'user_name' => $user_name)); echo 'Your message has been sent.'; } else { echo 'Please enter a valid email address.'; } die; } echo 'We\'re sorry, there was an error processing your request. Please try again.'; die; }
public static function get_clients_ajax() { check_ajax_referer('displet_get_clients_nonce'); if (isset($_POST['action']) && $_POST['action'] == 'displet_get_clients_request') { $args = array('orderby' => 'display_name'); if (current_user_can('manage_options')) { $clients = DispletRetsIdxLeadsModel::get_users(false, $args); } else { $user_id = get_current_user_id(); if (!empty($user_id)) { $clients = DispletRetsIdxLeadsModel::get_users($user_id, $args); } } if (!empty($clients) && is_array($clients)) { $output = array(); foreach ($clients as $client) { $output[] = array('name' => $client->display_name, 'id' => $client->ID); } echo json_encode($output); } else { echo 'No matching users.'; } } else { echo 'There was an error processing your request. Please try again.'; } die; }
public static function upgrade_users_to_role_2() { $leads = DispletRetsIdxLeadsModel::get_users(); if (!empty($leads)) { foreach ($leads as $lead) { $name = get_user_meta($lead->ID, 'nickname', true); $names = DispletRetsIdxUsersModel::get_first_and_last_name($name); if (!empty($names)) { wp_update_user(array('ID' => $lead->ID, 'display_name' => $names['first_name'])); update_user_meta($lead->ID, 'first_name', $names['first_name']); update_user_meta($lead->ID, 'last_name', $names['last_name']); } $api_user_id = get_user_meta($lead->ID, 'displet_api_user_id', true); if (empty($api_user_id)) { $api_user_id = DispletRetsIdxUsersApiController::create_user($lead->user_email, $names['first_name'], $names['last_name']); update_user_meta($lead->ID, 'displet_api_user_id', $api_user_id); } DispletRetsIdxSavedSearchesController::send_users_saved_searches_to_api($lead->ID, $api_user_id); } } }
private static function maybe_get_user_vars() { if (self::$_model['has_request_showing_popup']) { $user = DispletRetsIdxLeadsModel::get_current_user_data(); if (!empty($user)) { self::$_model['current_user_id'] = $user['id']; self::$_model['current_user_name'] = $user['name']; self::$_model['current_user_email'] = $user['email']; self::$_model['current_user_phone'] = $user['phone']; } /* $current_user = wp_get_current_user(); if ( !empty( $current_user->ID ) ) { self::$_model['current_user_id'] = $current_user->ID; self::$_model['current_user_name'] = $current_user->display_name; self::$_model['current_user_email'] = $current_user->user_email; self::$_model['current_user_phone'] = get_user_meta( $current_user->ID, 'displet_phone', true ); } */ } }
public static function maybe_update() { $last_version = DispletRetsIdxOptionsController::get_option('version'); // If last version still using old update methodology if (empty($last_version) || version_compare('2.0.26', $last_version, '>')) { $user_role_version = get_option('displet_rets_idx_user_role_version'); if (empty($user_role_version) || $user_role_version < 2) { DispletRetsIdxLeadsModel::add_custom_user_role_for_leads(); if ($user_role_version < 2) { DispletRetsIdxUsersUpdatesController::upgrade_users_to_role_2(); } } $version = get_option('displet_rets_idx_options_version'); if (empty($version) || $version < 1) { if (empty($version) || $version < 1) { DispletRetsIdxSettingsUpdatesController::update_settings_to_version_1(); } update_option('displet_rets_idx_options_version', 1); } } // If last version not current if (version_compare(self::$_version, $last_version, '>')) { if (version_compare('2.0.24', $last_version, '>')) { self::update_to_2_0_24(); } if (version_compare('2.0.25', $last_version, '>')) { self::update_to_2_0_25(); } if (version_compare('2.0.26', $last_version, '>')) { self::update_to_2_0_26(); } if (version_compare('2.0.27', $last_version, '>')) { self::update_to_2_0_27(); } if (version_compare('2.0.30', $last_version, '>')) { self::update_to_2_0_30(); } if (version_compare('2.0.31', $last_version, '>')) { self::update_to_2_0_31(); } if (version_compare('2.0.46', $last_version, '>')) { self::update_to_2_0_46(); } if (version_compare('2.1', $last_version, '>')) { self::update_to_2_1(); } if (version_compare('2.1.4', $last_version, '>')) { self::update_to_2_1_4(); } if (version_compare('2.1.10', $last_version, '>')) { self::update_to_2_1_10(); } if (version_compare('2.1.17', $last_version, '>')) { self::update_to_2_1_17(); } if (version_compare('2.1.18', $last_version, '>')) { self::update_to_2_1_18(); } if (version_compare('2.1.19', $last_version, '>')) { self::update_to_2_1_19(); } DispletRetsIdxOptionsController::update_option('version', self::$_version); } }
public static function submit_registration_ajax() { check_ajax_referer('displet_register_user_nonce'); if (isset($_POST['action']) && $_POST['action'] == 'displet_user_registration_request') { if (!empty($_POST['name']) && !empty($_POST['email']) && (empty(self::$_options['require_phone']) || !empty($_POST['phone'])) && (empty(self::$_options['require_working_with_realtor']) || empty(self::$_options['include_working_with_realtor']) || !empty($_POST['realtor']))) { if (is_email($_POST['email'])) { $is_blacklisted_email = DispletRetsIdxLeadsModel::is_blacklisted_email($_POST['email']); $is_blacklisted_name = DispletRetsIdxLeadsModel::is_blacklisted_name($_POST['name']); if (!empty($is_blacklisted_email)) { echo 'We\'re sorry, the email address provided has been prohibited.'; } else { if (!empty($is_blacklisted_name)) { echo 'We\'re sorry, the name provided has been prohibited.'; } else { $result = DispletRetsIdxLeadsController::create_new_re_search_user(array('email' => $_POST['email'], 'name' => $_POST['name'], 'phone' => $_POST['phone'], 'realtor' => $_POST['realtor'], 'url' => $_POST['url'], 'upstream_url' => $_POST['upstream_url'], 'last_hash' => $_POST['last_hash'], 'listing_agent_email' => $_POST['listing_agent_email'], 'user_address' => $_POST['user_address'], 'user_address_time' => $_POST['user_address_time'])); if (!empty($result['success'])) { echo 'Successful Registration'; } else { echo $result; } } } } else { echo 'Please enter a valid email address.'; } } else { echo 'Please complete the required fields.'; } die; } echo 'We\'re sorry, there was an error processing your request. Please try again.'; die; }