���� JFIF �� � ( %"1"%)+...383,7(-.-
![]() Server : Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.20 System : Linux st2.domain.com 3.10.0-1127.10.1.el7.x86_64 #1 SMP Wed Jun 3 14:28:03 UTC 2020 x86_64 User : apache ( 48) PHP Version : 7.4.20 Disable Function : NONE Directory : /var/www/html/form/content/plugins/halfdata-green-forms/modules/ |
<?php /* Create / update WordPress user. */ if (!defined('UAP_CORE') && !defined('ABSPATH')) exit; class leform_wpuser_class { var $default_parameters = array( 'role' => 'subscriber', 'fields' => array( 'user_email' => '', 'user_pass' => '', 'first_name' => '', 'last_name' => '', 'user_url' => '' ), 'notification' => 'on', 'allow-update' => 'off' ); var $field_labels = array( 'user_email' => array('title' => 'Email', 'description' => 'E-mail address of the user.'), 'user_pass' => array('title' => 'Password', 'description' => 'Password of the user.'), 'first_name' => array('title' => 'First name', 'description' => 'First name of the user.'), 'last_name' => array('title' => 'Last name', 'description' => 'Last name of the user.'), 'user_url' => array('title' => 'Website URL', 'description' => 'Website URL of the user.') ); function __construct() { if (is_admin()) { add_filter('leform_providers', array(&$this, 'providers'), 10, 1); add_action('wp_ajax_leform-wpuser-settings-html', array(&$this, "admin_settings_html")); } add_filter('leform_integrations_do_wpuser', array(&$this, 'front_submit'), 10, 2); } function providers($_providers) { if (!array_key_exists("wpuser", $_providers)) $_providers["wpuser"] = esc_html__('WP User', 'leform'); return $_providers; } function admin_settings_html() { global $wpdb, $leform; if (current_user_can('manage_options')) { if (array_key_exists('data', $_REQUEST)) { $data = json_decode(base64_decode(trim(stripslashes($_REQUEST['data']))), true); if (is_array($data)) $data = array_merge($this->default_parameters, $data); else $data = $this->default_parameters; } else $data = $this->default_parameters; $checkbox_id = $leform->random_string(); $html = ' <div class="leform-properties-item"> <div class="leform-properties-label"> <label>'.esc_html__('User role', 'leform').'</label> </div> <div class="leform-properties-tooltip"> <i class="fas fa-question-circle leform-tooltip-anchor"></i> <div class="leform-tooltip-content">'.esc_html__('Select the role for the newly created user.', 'leform').'</div> </div> <div class="leform-properties-content"> <select type="text" name="role" value="'.esc_html($data['role']).'">'; $roles = get_editable_roles(); foreach ($roles as $key => $value) { $html .= ' <option'.($data['role'] == $key ? ' selected="selected"' : '').' value="'.esc_html($key).'">'.esc_html($value['name']).'</option>'; } $html .= ' </select> </div> </div>'; $html .= ' <div class="leform-properties-item"> <div class="leform-properties-label"> <label>'.esc_html__('Fields', 'leform').'</label> </div> <div class="leform-properties-tooltip"> <i class="fas fa-question-circle leform-tooltip-anchor"></i> <div class="leform-tooltip-content">'.esc_html__('Map form fields to WP User fields.', 'leform').'</div> </div> <div class="leform-properties-content"> <div class="leform-properties-pure leform-integrations-static-inline"> <table>'; foreach ($this->default_parameters['fields'] as $key => $value) { $html .= ' <tr> <th>'.esc_html($this->field_labels[$key]['title']).'</th> <td> <div class="leform-input-shortcode-selector"> <input type="text" name="fields['.esc_html($key).']" value="'.(array_key_exists($key, $data['fields']) ? esc_html($data['fields'][$key]) : '').'" class="widefat" /> <div class="leform-shortcode-selector" onmouseover="leform_shortcode_selector_set(this)";><span><i class="fas fa-code"></i></span></div> </div> <label class="leform-integrations-description">'.esc_html($this->field_labels[$key]['description']).'</label> </td> </tr>'; } $html .= ' </table> </div> </div> </div> <div class="leform-properties-item"> <div class="leform-properties-label"> <label>'.esc_html__('User notification', 'leform').'</label> </div> <div class="leform-properties-tooltip"> <i class="fas fa-question-circle leform-tooltip-anchor"></i> <div class="leform-tooltip-content">'.esc_html__('Email login credentials to a newly-registered user (standard WP message). This option should be enabled if you did not request a password from the user.', 'leform').'</div> </div> <div class="leform-properties-content"> <input class="leform-checkbox-toggle" type="checkbox" value="on" id="notification-'.esc_html($checkbox_id).'" name="notification"'.($data['notification'] == 'on' ? ' checked="checked"' : '').' /><label for="notification-'.esc_html($checkbox_id).'"></label> </div> </div> <div class="leform-properties-item"> <div class="leform-properties-label"> <label>'.esc_html__('Allow updates', 'leform').'</label> </div> <div class="leform-properties-tooltip"> <i class="fas fa-question-circle leform-tooltip-anchor"></i> <div class="leform-tooltip-content">'.esc_html__('Update user data for already existing users. Existing user must have the same user role.', 'leform').'</div> </div> <div class="leform-properties-content"> <input class="leform-checkbox-toggle" type="checkbox" value="on" id="allow-update-'.esc_html($checkbox_id).'" name="allow-update"'.($data['allow-update'] == 'on' ? ' checked="checked"' : '').' /><label for="allow-update-'.esc_html($checkbox_id).'"></label> </div> </div>'; $return_object = array(); $return_object['status'] = 'OK'; $return_object['html'] = $html; echo json_encode($return_object); } exit; } function front_submit($_result, $_data) { global $wpdb, $leform; $data = array_merge($this->default_parameters, $_data); if (empty($data['fields']) || !is_array($data['fields'])) return $_result; $data['fields']['user_pass'] = trim($data['fields']['user_pass']); if (empty($data['fields']['user_pass']) && $data['notification'] != 'on') return $_result; if (empty($data['fields']['user_email']) || !preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,19})$/i", $data['fields']['user_email'])) return $_result; $post_data = array( 'role' => $data['role'], 'user_email' => $data['fields']['user_email'], 'user_login' => $data['fields']['user_email'] ); foreach ($data['fields'] as $key => $value) { if (!empty($value) && $key != 'user_email' && $key != 'user_login' && $key != 'user_pass') { $post_data[$key] = $value; } } $user_id = username_exists($data['fields']['user_email']); if (!$user_id) $user_id = email_exists($data['fields']['user_email']); if (!$user_id) { if (empty($data['fields']['user_pass'])) $post_data['user_pass'] = wp_generate_password(); else $post_data['user_pass'] = $data['fields']['user_pass']; $user_id = wp_insert_user($post_data); if (!is_wp_error($user_id)) { if ($data['notification'] == 'on') { wp_new_user_notification($user_id, null, 'both'); } } } else { if ($data['allow-update'] == 'on') { $user = get_userdata($user_id); if ($user) { if (in_array($data['role'], $user->roles)) { $post_data['ID'] = $user_id; wp_update_user($post_data); } } } } return $_result; } } $leform_wpuser = new leform_wpuser_class(); ?>