/** * Handles sending password retrieval email to user. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @return bool|WP_Error True: when finish. WP_Error on error. */ function geodir_retrieve_password() { global $wpdb; $errors = new WP_Error(); if (empty($_POST['user_login']) && empty($_POST['user_email'])) { $errors->add('empty_username', __('<strong>ERROR</strong>: Enter a username or e-mail address.', 'geodirectory')); } if (strpos($_POST['user_login'], '@')) { //$user_data = get_user_by_email(trim($_POST['user_login'])); $user_data = get_user_by('email', trim($_POST['user_login'])); if (empty($user_data)) { $errors->add('invalid_email', __('<strong>ERROR</strong>: There is no user registered with that email address.', 'geodirectory')); } } else { $login = trim($_POST['user_login']); $user_data = get_user_by('email', $login); } /** * Called in the geodir_retrieve_password() function before any errors are set or any emails are sent. * * @since 1.0.0 */ do_action('lostpassword_post'); if ($errors->get_error_code()) { return $errors; } if (!$user_data) { $errors->add('invalidcombo', __('<strong>ERROR</strong>: Invalid username or e-mail.', 'geodirectory')); return $errors; } // redefining user_login ensures we return the right case in the email $user_login = $user_data->user_login; $user_email = $user_data->user_email; /** * Called in the geodir_retrieve_password() function before any emails are sent. * * @since 1.0.0 * @param string $user_login The users username. */ do_action('retrieve_password', $user_login); //////////////////////////////////// $user_email = isset($_POST['user_email']) ? $_POST['user_email'] : ''; $user_login = $_POST['user_login']; $user = $wpdb->get_row($wpdb->prepare("SELECT * FROM {$wpdb->users} WHERE user_login like %s or user_email like %s", array($user_login, $user_login))); if (empty($user)) { return new WP_Error('invalid_key', __('Invalid key', 'geodirectory')); } $new_pass = wp_generate_password(12, false); /** * Called in the geodir_retrieve_password() function before any emails are sent. * * @since 1.0.0 * @param object $user The user object. * @param string $new_pass The new pass being sent to the user. */ do_action('password_reset', $user, $new_pass); wp_set_password($new_pass, $user->ID); update_user_meta($user->ID, 'default_password_nag', true); //Set up the Password change nag. $message = '<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p>'; $message .= '<p>' . sprintf(__('Username: %s', 'geodirectory'), $user->user_login) . "</p>"; $message .= '<p>' . sprintf(__('Password: %s', 'geodirectory'), $new_pass) . "</p>"; //$message .= '<p>You can login to : <a href="'.home_url().'/?ptype=login' . "\">Login</a> or the URL is : ".home_url()."/?ptype=login</p>"; //$message .= '<p>Thank You,<br> '.get_option('blogname').'</p>'; $user_email = $user_data->user_email; $user_name = geodir_get_client_name($user->ID); $fromEmail = geodir_get_site_email_id(); $fromEmailName = get_site_emailName(); $title = sprintf(__('[%s] Your new password', 'geodirectory'), get_option('blogname')); /** * Filter the password reset email subject part. * * @since 1.0.0 * * @param string $title Password reset email subject. */ $title = apply_filters('password_reset_title', $title); /** * Filter the password reset email message part. * * @since 1.0.0 * * @param string $message Password reset email message. * @param string $new_pass The new password string. */ $message = apply_filters('password_reset_message', $message, $new_pass); //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$user_name,$title,$message,$extra='');///forgot password email geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $user_name, $title, $message, $extra = '', 'forgot_password', $post_id = '', $user->ID); ///forgot password email return true; }
/** * Send emails to client on post submission, renew etc. * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @param int|string $page_id Page ID. * @param int|string $user_id User ID. * @param string $message_type Can be 'expiration','post_submited','renew','upgrade','claim_approved','claim_rejected','claim_requested','auto_claim','payment_success','payment_fail'. * @param string $custom_1 Custom data to be sent. */ function adminEmail($page_id, $user_id, $message_type, $custom_1 = '') { global $wpdb; if ($message_type == 'expiration') { $subject = stripslashes(get_option('renew_email_subject')); $client_message = stripslashes(get_option('renew_email_content')); } elseif ($message_type == 'post_submited') { $subject = get_option('post_submited_success_email_subject_admin'); $client_message = get_option('post_submited_success_email_content_admin'); } elseif ($message_type == 'renew') { $subject = get_option('post_renew_success_email_subject_admin'); $client_message = get_option('post_renew_success_email_content_admin'); } elseif ($message_type == 'upgrade') { $subject = get_option('post_upgrade_success_email_subject_admin'); $client_message = get_option('post_upgrade_success_email_content_admin'); } elseif ($message_type == 'claim_approved') { $subject = get_option('claim_approved_email_subject'); $client_message = get_option('claim_approved_email_content'); } elseif ($message_type == 'claim_rejected') { $subject = get_option('claim_rejected_email_subject'); $client_message = get_option('claim_rejected_email_content'); } elseif ($message_type == 'claim_requested') { $subject = get_option('claim_email_subject_admin'); $client_message = get_option('claim_email_content_admin'); } elseif ($message_type == 'auto_claim') { $subject = get_option('auto_claim_email_subject'); $client_message = get_option('auto_claim_email_content'); } elseif ($message_type == 'payment_success') { $subject = get_option('post_payment_success_admin_email_subject'); $client_message = get_option('post_payment_success_admin_email_content'); } elseif ($message_type == 'payment_fail') { $subject = get_option('post_payment_fail_admin_email_subject'); $client_message = get_option('post_payment_fail_admin_email_content'); } $transaction_details = $custom_1; $fromEmail = get_option('site_email'); $fromEmailName = get_site_emailName(); //$alivedays = get_post_meta($page_id,'alive_days',true); $pkg_limit = get_property_price_info_listing($page_id); $alivedays = $pkg_limit['days']; $productlink = get_permalink($page_id); $post_info = get_post($page_id); $post_date = date('dS F,Y', strtotime($post_info->post_date)); $listingLink = '<a href="' . $productlink . '"><b>' . $post_info->post_title . '</b></a>'; $loginurl = home_url() . '/?ptype=login'; $loginurl_link = '<a href="' . $loginurl . '">login</a>'; $siteurl = home_url(); $siteurl_link = '<a href="' . $siteurl . '">' . $fromEmailName . '</a>'; $user_info = get_userdata($user_id); $user_email = $user_info->user_email; $display_name = geodir_get_client_name($user_id); $user_login = $user_info->user_login; $number_of_grace_days = get_option('ptthemes_listing_preexpiry_notice_days'); if ($number_of_grace_days == '') { $number_of_grace_days = 1; } if ($post_info->post_type == 'event') { $post_type = 'event'; } else { $post_type = 'listing'; } $renew_link = '<a href="' . $siteurl . '?ptype=post_' . $post_type . '&renew=1&pid=' . $page_id . '">' . RENEW_LINK . '</a>'; $search_array = array('[#client_name#]', '[#listing_link#]', '[#posted_date#]', '[#number_of_days#]', '[#number_of_grace_days#]', '[#login_url#]', '[#username#]', '[#user_email#]', '[#site_name_url#]', '[#renew_link#]', '[#post_id#]', '[#site_name#]', '[#transaction_details#]'); $replace_array = array($display_name, $listingLink, $post_date, $alivedays, $number_of_grace_days, $loginurl_link, $user_login, $user_email, $siteurl_link, $renew_link, $page_id, $fromEmailName, $transaction_details); $client_message = str_replace($search_array, $replace_array, $client_message); $subject = str_replace($search_array, $replace_array, $subject); $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=UTF-8' . "\r\n"; //$headers .= 'To: <'.$fromEmail.'>' . "\r\n"; $headers .= 'From: ' . $fromEmailName . ' <' . $fromEmail . '>' . "\r\n"; @wp_mail($fromEmail, $subject, $client_message, $headers); ///To client email }
/** * Send enquiry to listing author * * This function let the user to send Enquiry to listing author. If listing author email not available, then admin email will be used. * Email content will be used WP Admin -> Geodirectory -> Notifications -> Other Emails -> Email enquiry * * @since 1.0.0 * @package GeoDirectory * @global object $wpdb WordPress Database object. * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "send_inqury". * @type string $pid Post ID. * @type string $inq_name Sender name. * @type string $inq_email Sender mail. * @type string $inq_phone Sender phone. * @type string $inq_msg Email message. * * } */ function geodir_send_inquiry($request) { global $wpdb; // strip slashes from text $request = !empty($request) ? stripslashes_deep($request) : $request; $yourname = $request['inq_name']; $youremail = $request['inq_email']; $inq_phone = $request['inq_phone']; $frnd_comments = $request['inq_msg']; $pid = $request['pid']; $author_id = ''; $post_title = ''; if ($request['pid']) { $productinfosql = $wpdb->prepare("select ID,post_author,post_title from {$wpdb->posts} where ID =%d", array($request['pid'])); $productinfo = $wpdb->get_row($productinfosql); $author_id = $productinfo->post_author; $post_title = $productinfo->post_title; } $post_title = '<a href="' . get_permalink($pid) . '">' . $post_title . '</a>'; $user_info = get_userdata($author_id); $to_email = geodir_get_post_meta($pid, 'geodir_email', true); $to_name = geodir_get_client_name($author_id); if ($to_email == '') { $to_email = get_option('admin_email'); } /** * Called after the send enquiry var have been set but before the email has been sent. * * @since 1.0.0 * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "send_inqury". * @type string $pid Post ID. * @type string $inq_name Sender name. * @type string $inq_email Sender mail. * @type string $inq_phone Sender phone. * @type string $inq_msg Email message. * * } * @param string $type The form type, default: `Enquiry`. */ do_action('geodir_after_send_enquiry', $request, 'Enquiry'); $client_message = $frnd_comments; $client_message .= '<br>' . __('From :', 'geodirectory') . ' ' . $yourname . '<br>' . __('Phone :', 'geodirectory') . ' ' . $inq_phone . '<br>' . __('Email :', 'geodirectory') . ' ' . $youremail . '<br><br>' . __('Sent from', 'geodirectory') . ' - <b><a href="' . trailingslashit(home_url()) . '">' . get_option('blogname') . '</a></b>.'; /** * Filter client message text. * * @since 1.0.0 * @param string $client_message Client message text. */ $client_message = apply_filters('geodir_inquiry_email_msg', $client_message); /** * Called before the send enquiry email is sent. * * @since 1.0.0 * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "send_inqury". * @type string $pid Post ID. * @type string $inq_name Sender name. * @type string $inq_email Sender mail. * @type string $inq_phone Sender phone. * @type string $inq_msg Email message. * * } */ do_action('geodir_before_send_enquiry_email', $request); if ($to_email) { // strip slashes message $client_message = stripslashes_deep($client_message); geodir_sendEmail($youremail, $yourname, $to_email, $to_name, '', $client_message, $extra = '', 'send_enquiry', $request['pid']); //To client email } /** * Called after the send enquiry email is sent. * * @since 1.0.0 * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "send_inqury". * @type string $pid Post ID. * @type string $inq_name Sender name. * @type string $inq_email Sender mail. * @type string $inq_phone Sender phone. * @type string $inq_msg Email message. * * } */ do_action('geodir_after_send_enquiry_email', $request); $url = get_permalink($pid); if (strstr($url, '?')) { $url = $url . "&send_inquiry=success"; } else { $url = $url . "?send_inquiry=success"; } /** * Filter redirect url after the send enquiry email is sent. * * @since 1.0.0 * @param string $url Redirect url. */ $url = apply_filters('geodir_send_enquiry_after_submit_redirect', $url); wp_redirect($url); exit; }
/** * Called when post updated. * * @since 1.0.0 * @package GeoDirectory * @param int $post_ID The post ID. * @param object $post_after The post object after update. * @param object $post_before The post object before update. */ function geodir_function_post_updated($post_ID, $post_after, $post_before) { $post_type = get_post_type($post_ID); if ($post_type != '' && in_array($post_type, geodir_get_posttypes())) { // send notification to client when post moves from draft to publish if (!empty($post_after->post_status) && $post_after->post_status == 'publish' && !empty($post_before->post_status) && ($post_before->post_status == 'draft' || $post_before->post_status == 'auto-draft')) { $post_author_id = !empty($post_after->post_author) ? $post_after->post_author : NULL; $post_author_data = get_userdata($post_author_id); $to_name = geodir_get_client_name($post_author_id); $from_email = geodir_get_site_email_id(); $from_name = get_site_emailName(); $to_email = $post_author_data->user_email; if (!is_email($to_email) && !empty($post_author_data->user_email)) { $to_email = $post_author_data->user_email; } $message_type = 'listing_published'; if (get_option('geodir_post_published_email_subject') == '') { update_option('geodir_post_published_email_subject', __('Listing Published Successfully', GEODIRECTORY_TEXTDOMAIN)); } if (get_option('geodir_post_published_email_content') == '') { update_option('geodir_post_published_email_content', __("<p>Dear [#client_name#],</p><p>Your listing [#listing_link#] has been published. This email is just for your information.</p><p>[#listing_link#]</p><br><p>Thank you for your contribution.</p><p>[#site_name#]</p>", GEODIRECTORY_TEXTDOMAIN)); } /** * Called before sending the email when listing gets published. * * @since 1.0.0 * @package GeoDirectory * @param object $post_after The post object after update. * @param object $post_before The post object before update. */ do_action('geodir_before_listing_published_email', $post_after, $post_before); if (is_email($to_email)) { geodir_sendEmail($from_email, $from_name, $to_email, $to_name, '', '', '', $message_type, $post_ID); } /** * Called after sending the email when listing gets published. * * @since 1.0.0 * @package GeoDirectory * @param object $post_after The post object after update. * @param object $post_before The post object before update. */ do_action('geodir_after_listing_published_email', $post_after, $post_before); } } }