PluginProbe
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on / 1.6
Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on v1.6
2.0 1.7.1 1.2.9 1.3 1.4 1.4.1 1.4.2 1.4.3 1.5 1.6 1.7 trunk 1.0 1.1 1.2 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8
import-users / controllers / SendPassword.php

SendPassword.php in Import Users & Customers with Meta | WP Ultimate CSV Importer Add-on 1.6, at controllers/SendPassword.php

108 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Import Users plugin file.
4 *
5 * Copyright (C) 2010-2020, Smackcoders Inc - info@smackcoders.com
6 */
7
8 namespace Smackcoders\SMUSERS;
9
10 if ( ! defined( 'ABSPATH' ) )
11 exit; // Exit if accessed directly
12
13 /**
14 * Class SendPassword
15 * @package Smackcoders\SMUSERS
16 */
17 class SendPassword {
18
19 protected static $instance = null;
20
21 public static function getInstance() {
22 if ( null == self::$instance ) {
23 self::$instance = new self;
24 self::$instance->doHooks();
25 }
26 return self::$instance;
27 }
28
29 /**
30 * SendPassword constructor.
31 */
32 public function __construct() {
33 $this->plugin = Plugin::getInstance();
34 }
35
36 /**
37 * SendPassword hooks.
38 */
39 public function doHooks(){
40 add_action('wp_ajax_settings_options', array($this,'settingsOptions'));
41 add_action('wp_ajax_get_options', array($this,'showOptions'));
42 }
43
44 /**
45 * Function for save settings options
46 *
47 */
48 public function settingsOptions() {
49 check_ajax_referer('smack-ultimate-csv-importer', 'securekey');
50 $ucisettings = get_option('sm_uci_pro_settings');
51 $option = sanitize_text_field($_POST['option']);
52 $value = sanitize_text_field($_POST['value']);
53 foreach ($ucisettings as $key => $val) {
54 $settings[$key] = $val;
55 }
56 $settings[$option] = $value;
57 update_option('sm_uci_pro_settings', $settings);
58 $result['success'] = true;
59 echo wp_json_encode($result);
60 wp_die();
61 }
62
63 /**
64 * Function for show settings options
65 *
66 */
67 public function showOptions() {
68 check_ajax_referer('smack-ultimate-csv-importer', 'securekey');
69 $ucisettings = get_option('sm_uci_pro_settings');
70 foreach ($ucisettings as $key => $val) {
71 $settings[$key] = json_decode($val);
72 }
73 $result['options'] = $settings;
74 echo wp_json_encode($result);
75 wp_die();
76 }
77
78 /**
79 * send login credential to user
80 *
81 */
82 public function send_login_credentials_to_users() {
83
84 require_once(ABSPATH . "wp-includes/pluggable.php");
85 global $wpdb;
86 $ucisettings = get_option('sm_uci_pro_settings');
87 if($ucisettings['send_user_password'] == "true") {
88 $get_user_meta_info = $wpdb->get_results( $wpdb->prepare("select *from {$wpdb->prefix}usermeta where meta_key like %s", '%' . 'smack_uci_import' . '%') );
89 $get_send_password_info = $wpdb->get_results( $wpdb->prepare("select meta_value from {$wpdb->prefix}usermeta where meta_key like %s", '%' . 'sendPassword' . '%') );
90 $send_password=$get_send_password_info[0]->meta_value;
91 if(!empty($get_user_meta_info)) {
92 foreach($get_user_meta_info as $key => $value) {
93 $data_array = maybe_unserialize($value->meta_value);
94 $currentUser = wp_get_current_user();
95 $admin_email = $currentUser->user_email;
96 $em_headers = "From: Administrator <$admin_email>"; # . "\r\n";
97 $message = "Hi,You've been invited with the role of " . $data_array['role'] . ". Here, your login details." . "\n" . "username: " . $data_array['user_login'] . "\n" . "userpass: " . $send_password . "\n" . "Please click here to login " . wp_login_url();
98 $emailaddress = $data_array['user_email'];
99 $subject = 'Login Details';
100 if( wp_mail( $emailaddress, $subject, $message) ){
101 delete_user_meta($value->user_id, 'smack_uci_import');
102 }
103 }
104 }
105 }
106 }
107 }
108