/** * Send Email to a friend. * * This function let the user to send Email to a friend. * Email content will be used WP Admin -> Geodirectory -> Notifications -> Other Emails -> Send to friend * * @since 1.0.0 * @package GeoDirectory * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "email_frnd". * @type string $pid Post ID. * @type string $to_name Friend name. * @type string $to_email Friend email. * @type string $yourname Sender name. * @type string $youremail Sender email. * @type string $frnd_subject Email subject. * @type string $frnd_comments Email Message. * * } * @global object $wpdb WordPress Database object. */ function geodir_send_friend($request) { global $wpdb; // strip slashes from text $request = !empty($request) ? stripslashes_deep($request) : $request; $yourname = $request['yourname']; $youremail = $request['youremail']; $frnd_subject = $request['frnd_subject']; $frnd_comments = $request['frnd_comments']; $pid = $request['pid']; $to_email = $request['to_email']; $to_name = $request['to_name']; if ($request['pid']) { $productinfosql = $wpdb->prepare("select ID,post_title from {$wpdb->posts} where ID =%d", array($request['pid'])); $productinfo = $wpdb->get_results($productinfosql); foreach ($productinfo as $productinfoObj) { $post_title = $productinfoObj->post_title; } } /** * Called before the send to friend email is sent. * * @since 1.0.0 * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "email_frnd". * @type string $pid Post ID. * @type string $to_name Friend name. * @type string $to_email Friend email. * @type string $yourname Sender name. * @type string $youremail Sender email. * @type string $frnd_subject Email subject. * @type string $frnd_comments Email Message. * * } */ do_action('geodir_before_send_to_friend_email', $request); geodir_sendEmail($youremail, $yourname, $to_email, $to_name, $frnd_subject, $frnd_comments, $extra = '', 'send_friend', $request['pid']); //To client email /** * Called after the send to friend email is sent. * * @since 1.0.0 * @param array $request { * The submitted form fields as an array. * * @type string $sendact Enquiry type. Default "email_frnd". * @type string $pid Post ID. * @type string $to_name Friend name. * @type string $to_email Friend email. * @type string $yourname Sender name. * @type string $youremail Sender email. * @type string $frnd_subject Email subject. * @type string $frnd_comments Email Message. * * } */ do_action('geodir_after_send_to_friend_email', $request); $url = get_permalink($pid); if (strstr($url, '?')) { $url = $url . "&sendtofrnd=success"; } else { $url = $url . "?sendtofrnd=success"; } /** * Filter redirect url after the send to friend email is sent. * * @since 1.0.0 * @param string $url Redirect url. */ $url = apply_filters('geodir_send_to_friend_after_submit_redirect', $url); wp_redirect($url); exit; }
/** * Handles registering a new user. * * @since 1.0.0 * @package GeoDirectory * @param string $user_login User's username for logging in. * @param string $user_email User's email address to send password and add. * @global object $wpdb WordPress Database object. * @return int|WP_Error Either user's ID or error on failure. */ function geodir_register_new_user($user_login, $user_email) { global $wpdb; $errors = new WP_Error(); $user_login = sanitize_user($user_login); $user_login = str_replace(",", "", $user_login); $user_email = str_replace(",", "", $user_email); /** * Filter the user registration email. * * @since 1.0.0 * * @param string $user_email User registration email. */ $user_email = apply_filters('user_registration_email', $user_email); if (get_option('geodir_allow_cpass')) { $user_pass = $_REQUEST['user_pass']; $user_pass2 = $_REQUEST['user_pass2']; // Check the password if ($user_pass != $user_pass2) { $errors->add('pass_match', __('ERROR: Passwords do not match.', 'geodirectory')); } elseif (strlen($user_pass) < 7) { $errors->add('pass_match', __('ERROR: Password must be 7 characters or more.', 'geodirectory')); } } // Check the username if ($user_login == '') { $errors->add('empty_username', __('ERROR: Please enter a username.', 'geodirectory')); } elseif (!validate_username($user_login)) { $errors->add('invalid_username', __('<strong>ERROR</strong>: This username is invalid. Please enter a valid username.', 'geodirectory')); $user_login = ''; } elseif (username_exists($user_login)) { $errors->add('username_exists', __('<strong>ERROR</strong>: This username is already registered, please choose another one.', 'geodirectory')); } // Check the e-mail address if ($user_email == '') { $errors->add('empty_email', __('<strong>ERROR</strong>: Please type your e-mail address.', 'geodirectory')); } elseif (!is_email($user_email)) { $errors->add('invalid_email', __('<strong>ERROR</strong>: The email address isn’t correct.', 'geodirectory')); $user_email = ''; } elseif (email_exists($user_email)) { $errors->add('email_exists', __('<strong>ERROR</strong>: This email is already registered, please choose another one.', 'geodirectory')); } /** * Called when registering a new user. * * This is a WordPress core hook. * * @link https://codex.wordpress.org/Plugin_API/Action_Reference/register_post * @since 1.0.0 */ do_action('register_post', $user_login, $user_email, $errors); /** * Filter the registration error messages. * * @since 1.0.0 * * @param object $errors Registration error messages. */ $errors = apply_filters('registration_errors', $errors); if ($errors->get_error_code()) { return $errors; } if (!isset($user_pass) || $user_pass == '') { $user_pass = wp_generate_password(12, false); } $user_id = wp_create_user($user_login, $user_pass, $user_email); $user_web = ''; /*$user_add1 = $_POST['user_add1']; $user_add2 = $_POST['user_add2']; $user_city = $_POST['user_city']; $user_state = $_POST['user_state']; $user_country = $_POST['user_country']; $user_postalcode = $_POST['user_postalcode']; $user_web = $_POST['user_web']; $user_phone = $_POST['user_phone']; $user_twitter = $_POST['user_twitter']; */ $user_fname = sanitize_user($_POST['user_fname']); $user_fname = str_replace(",", "", $user_fname); /** * Filter the submitted user meta. * * @since 1.0.0 * * @param int $user_id User ID. */ $user_address_info = apply_filters('geodir_manage_user_meta', array("user_add1" => '', "user_add2" => '', "user_city" => '', "user_state" => '', "user_country" => '', "user_postalcode" => '', "user_phone" => '', "user_twitter" => '', "first_name" => $user_fname, "last_name" => ''), $user_id); foreach ($user_address_info as $key => $val) { update_user_meta($user_id, $key, $val); // User Address Information Here } //update_user_meta($user_id, 'user_address_info', ($user_address_info)); // User Address Information Here $userName = $user_fname; update_user_meta($user_id, 'first_name', $userName); // User Address Information Here //update_user_meta($user_id, 'last_name', $_POST['user_lname']); // User Address Information Here // Changed by vikas sharma to enable all type of characters in author permalink... $user_nicename = sanitize_title($userName); $updateUsersql = $wpdb->prepare("update {$wpdb->users} set user_url=%s, user_nicename=%s, display_name=%s where ID=%d", array($user_web, $user_nicename, $userName, $user_id)); $wpdb->query($updateUsersql); if (!$user_id) { $errors->add('registerfail', sprintf(__('<strong>ERROR</strong>: Couldn’t register you... please contact the <a href="mailto:%s">webmaster</a> !', 'geodirectory'), get_option('admin_email'))); return $errors; } global $upload_folder_path; if ($user_id) { /** * Called after registering a user and before the registration email is sent. * * @since 1.0.0 * @param int $user_id The user ID of the registered user. */ do_action('geodir_user_register', $user_id); ///////REGISTRATION EMAIL START////// $fromEmail = geodir_get_site_email_id(); $fromEmailName = get_site_emailName(); $message = __('<p><b>' . __('Your login Information :', 'geodirectory') . '</b></p> <p>' . __('Username:'******'geodirectory') . ' ' . $user_login . '</p> <p>' . __('Password:'******'geodirectory') . ' ' . $user_pass . '</p>'); /////////////customer email////////////// //geodir_sendEmail($fromEmail,$fromEmailName,$user_email,$userName,$subject,$client_message,$extra='');///To client email geodir_sendEmail($fromEmail, $fromEmailName, $user_email, $userName, '', $message, '', 'registration', '', $user_id); /// registration email //////REGISTRATION EMAIL END//////// } if (get_option('ptthemes_auto_login')) { $errors->add('auto_login', __('<strong>SUCCESS</strong>: Thank you for registering, please check your email for your login details.', 'geodirectory')); return $errors; } return array($user_id, $user_pass); }
/** * 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); } } }