PluginProbe
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP / 1.2.74
UsersWP – Front-end login form, User Registration, User Profile & Members Directory plugin for WP v1.2.74
1.2.74 1.2.73 1.2.72 1.2.71 1.2.70 1.2.69 1.2.68 1.2.67 1.2.66 1.2.65 1.2.64 1.2.63 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 All 174 releases
← All changes | includes/class-activator.php +479 -441 1.0.191.2.74 View file →
@@ -8,9 +8,33 @@
8 8 * @author GeoDirectory Team <info@wpgeodirectory.com>
9 9 */
10 10 class UsersWP_Activator {
11 11
12 + /** @var array DB updates and callbacks that need to be run per version */
13 + private static $db_updates = array(
14 + '1.2.0.0' => array(
15 + 'uwp_upgrade_1200',
16 + ),
17 + '1.2.0.13' => array(
18 + 'uwp_upgrade_12013',
19 + ),
20 + '1.2.2.5' => array(
21 + 'uwp_upgrade_1225',
22 + ),
23 + '1.2.3' => array(
24 + 'uwp_upgrade_1230',
25 + ),
26 + );
27 +
28 +
12 29 /**
30 + * Background update class.
31 + *
32 + * @var object
33 + */
34 + private static $background_updater;
35 +
36 + /**
13 37 * This method gets fired during plugin activation.
14 38 *
15 39 * @since 1.0.0
16 40 * @package userswp
@@ -15,19 +39,22 @@
15 39 * @since 1.0.0
16 40 * @package userswp
17 41 * @return void
18 42 */
19 - public static function activate($network_wide = false) {
43 + public static function activate( $network_wide = false ) {
20 44
21 - self::load_dependencies();
45 + if ( is_multisite() ) {
46 + $main_site = get_network()->site_id;
47 + if ( $network_wide ) {
22 48
23 - if (is_multisite()) {
24 - $main_site = get_network()->site_id;
25 - if($network_wide){
26 - if (defined('UWP_ROOT_PAGES')) {
27 - if (UWP_ROOT_PAGES == 'all') {
28 - $blog_ids = self::uwp_get_blog_ids();
49 + update_network_option( '', 'uwp_is_network_active', 1 );
50 + switch_to_blog( $main_site );
51 + restore_current_blog();
29 52
53 + if ( defined( 'UWP_ROOT_PAGES' ) ) {
54 + if ( UWP_ROOT_PAGES == 'all' ) {
55 + $blog_ids = self::get_blog_ids();
56 +
30 57 foreach ( $blog_ids as $blog_id ) {
31 58 switch_to_blog( $blog_id );
32 59 self::install();
33 60 }
@@ -42,42 +69,53 @@
42 69 switch_to_blog( $main_site );
43 70 self::install();
44 71 restore_current_blog();
45 72 }
46 -
47 - switch_to_blog( $main_site );
48 - self::uwp101_create_tables();
49 - self::uwp_insert_usermeta();
50 - restore_current_blog();
51 - } else {
73 +} else {
52 74 self::install();
53 - self::uwp101_create_tables();
54 - self::uwp_insert_usermeta();
55 75 }
56 76 } else {
57 77 self::install();
58 - self::uwp101_create_tables();
59 - self::uwp_insert_usermeta();
60 78 }
79 + }
61 80
62 - }
81 + public static function install() {
63 82
64 - public static function install(){
83 + uwp_generate_default_pages();
84 + self::add_default_options();
85 + uwp_create_tables();
65 86
66 - self::generate_pages();
67 - self::uwp_create_tables();
87 + // run update functions if needed
88 + if ( self::needs_db_update() ) {
89 + self::update();
90 + }
68 91
69 - if (!get_option('uwp_default_data_installed')) {
70 - self::add_default_options();
71 - self::uwp_create_default_fields();
72 - self::uwp_insert_form_extras();
73 - update_option('uwp_default_data_installed', 1);
74 - update_option('uwp_activation_redirect', 1);
92 + if ( ! get_option( 'uwp_default_data_installed' ) ) {
93 + // new install
94 + self::create_default_fields();
95 + self::insert_form_extras();
96 + update_option( 'uwp_default_data_installed', 1 );
97 + update_option( 'uwp_activation_redirect', 1 );
98 + } else {
99 + // upgrade
100 + // if updating from < 1.2.0 then add the try bootstrap notice
101 + if ( version_compare( get_option( 'uwp_db_version', null ), '1.2.0', '<' ) ) {
102 + update_option( 'uwp_notice_try_bootstrap', true );
103 + uwp_update_option( 'design_style', '' );
104 + }
75 105 }
76 106
77 - self::uwp_flush_rewrite_rules();
78 - update_option('uwp_flush_rewrite', 1);
107 + self::flush_rewrite_rules();
108 + update_option( 'uwp_flush_rewrite', 1 );
79 109
110 + // update the version
111 + update_option( 'uwp_db_version', USERSWP_VERSION );
112 +
113 + $installed = get_option( 'uwp_installed_on' );
114 +
115 + if ( empty( $installed ) ) {
116 + update_option( 'uwp_installed_on', time() );
117 + }
80 118 }
81 119
82 120 /**
83 121 * Get all IDs of blogs that are not activated, not spam, and not deleted
@@ -84,9 +122,9 @@
84 122 *
85 123 * @global object $wpdb
86 124 * @return array|false Array of IDs or false if none are found
87 125 */
88 - public static function uwp_get_blog_ids() {
126 + public static function get_blog_ids() {
89 127 global $wpdb;
90 128
91 129 // Get an array of IDs
92 130 $sql = "SELECT blog_id FROM $wpdb->blogs
@@ -96,35 +134,8 @@
96 134 return $wpdb->get_col( $sql );
97 135 }
98 136
99 137 /**
100 - * Loads all dependencies during plugin activation.
101 - *
102 - * @since 1.0.0
103 - * @package userswp
104 - * @return void
105 - */
106 - public static function load_dependencies() {
107 -
108 - require_once dirname( __FILE__ ) .'/helpers.php' ;
109 - require_once dirname( __FILE__ ) . '/class-tables.php';
110 - require_once dirname( __FILE__ ) . '/class-meta.php';
111 - require_once dirname( __FILE__ ) . '/class-pages.php';
112 - require_once dirname(dirname( __FILE__ )) . '/admin/settings/class-formbuilder.php';
113 - }
114 -
115 - /**
116 - * Generates the default pages during plugin activation.
117 - *
118 - * @since 1.0.0
119 - * @package userswp
120 - * @return void
121 - */
122 - public static function generate_pages() {
123 - uwp_generate_default_pages();
124 - }
125 -
126 - /**
127 138 * Adds default settings during plugin activation.
128 139 *
129 140 * @since 1.0.0
130 141 * @package userswp
@@ -131,186 +142,158 @@
131 142 * @return void
132 143 */
133 144 public static function add_default_options() {
134 145
135 - $settings = get_option( 'uwp_settings', array());
146 + $settings = get_option( 'uwp_settings', array() );
136 147
137 - //general
138 - if (!isset($settings['profile_no_of_items'])) {
139 - $settings['profile_no_of_items'] = '10';
140 - }
148 + $options = array(
149 + 'register_modal' => 1,
150 + 'uwp_registration_action' => 'auto_approve',
151 + 'wp_register_redirect' => 1,
152 + 'login_modal' => 1,
153 + 'login_redirect_to' => -1,
154 + 'block_wp_login' => 0,
155 + 'disable_wp_2fa' => 0,
156 + 'forgot_modal' => 1,
157 + 'change_enable_old_password' => 1,
158 + 'change_disable_password_nag' => 0,
159 + 'enable_profile_header' => 1,
160 + 'enable_profile_body' => 1,
161 + 'profile_avatar_size' => '',
162 + 'profile_banner_size' => '',
163 + 'profile_banner_width' => 1000,
164 + 'profile_no_of_items' => 10,
165 + 'users_no_of_items' => 10,
166 + 'uwp_disable_author_link' => 0,
167 + 'users_default_layout' => '3col',
168 + 'author_box_enable_disable' => 1,
169 + 'author_box_display_content' => 'below_content',
170 + 'author_box_display_post_types' => array( 'post' ),
171 + 'author_box_content' => '',
172 + 'author_box_bio_limit' => 200,
173 + 'registration_success_email_admin' => 1,
174 + 'registration_success_email_subject_admin' => UsersWP_Defaults::registration_success_email_subject_admin(),
175 + 'registration_success_email_content_admin' => UsersWP_Defaults::registration_success_email_content_admin(),
176 + 'registration_activate_email' => 1,
177 + 'registration_activate_email_subject' => UsersWP_Defaults::registration_activate_email_subject(),
178 + 'registration_activate_email_content' => UsersWP_Defaults::registration_activate_email_content(),
179 + 'registration_success_email' => 1,
180 + 'registration_success_email_subject' => UsersWP_Defaults::registration_success_email_subject(),
181 + 'registration_success_email_content' => UsersWP_Defaults::registration_success_email_content(),
182 + 'forgot_password_email' => 1,
183 + 'forgot_password_email_subject' => UsersWP_Defaults::forgot_password_email_subject(),
184 + 'forgot_password_email_content' => UsersWP_Defaults::forgot_password_email_content(),
185 + 'change_password_email' => 1,
186 + 'change_password_email_subject' => UsersWP_Defaults::change_password_email_subject(),
187 + 'change_password_email_content' => UsersWP_Defaults::change_password_email_content(),
188 + 'reset_password_email' => 1,
189 + 'reset_password_email_subject' => UsersWP_Defaults::reset_password_email_subject(),
190 + 'reset_password_email_content' => UsersWP_Defaults::reset_password_email_content(),
191 + 'account_update_email' => 1,
192 + 'account_update_email_subject' => UsersWP_Defaults::account_update_email_subject(),
193 + 'account_update_email_content' => UsersWP_Defaults::account_update_email_content(),
194 + 'account_delete_email' => 1,
195 + 'account_delete_email_subject' => UsersWP_Defaults::account_delete_email_subject(),
196 + 'account_delete_email_content' => UsersWP_Defaults::account_delete_email_content(),
197 + 'account_delete_email_admin' => 1,
198 + 'account_delete_email_subject_admin' => UsersWP_Defaults::account_delete_email_subject_admin(),
199 + 'account_delete_email_content_admin' => UsersWP_Defaults::account_delete_email_content_admin(),
200 + 'wp_new_user_notification_email' => 1,
201 + 'wp_new_user_notification_email_subject' => UsersWP_Defaults::wp_new_user_notification_email_subject(),
202 + 'wp_new_user_notification_email_content' => UsersWP_Defaults::wp_new_user_notification_email_content(),
203 + 'account_new_email_activation_email' => 1,
204 + 'account_new_email_activation_email_subject' => UsersWP_Defaults::account_new_email_activation_email_subject(),
205 + 'account_new_email_activation_email_content' => UsersWP_Defaults::account_new_email_activation_email_content(),
206 + 'wp_new_user_notification_email_admin' => 1,
207 + 'wp_new_user_notification_email_subject_admin' => UsersWP_Defaults::wp_new_user_notification_email_subject_admin(),
208 + 'wp_new_user_notification_email_content_admin' => UsersWP_Defaults::wp_new_user_notification_email_content_admin(),
209 + 'user_post_counts_cpts' => array( 'post' ),
210 + 'login_user_post_counts_cpts' => array( 'post' ),
211 + 'multiple_registration_forms' => uwp_get_default_form_data(),
212 + 'profile_seo_meta_description_length' => 150,
213 + );
141 214
142 - //login
143 - if (!isset($settings['login_redirect_to'])) {
144 - $settings['login_redirect_to'] = -1;
145 - }
146 -
147 - //profile
148 - if (!isset($settings['enable_profile_header'])) {
149 - $settings['enable_profile_header'] = '1';
150 - }
151 - if (!isset($settings['enable_profile_body'])) {
152 - $settings['enable_profile_body'] = '1';
153 - }
154 - if (!isset($settings['enable_profile_posts_tab'])) {
155 - $settings['enable_profile_posts_tab'] = '1';
156 - }
157 - if (!isset($settings['enable_profile_comments_tab'])) {
158 - $settings['enable_profile_comments_tab'] = '1';
159 - }
160 -
161 - if (isset($settings['enable_profile_tabs']) && is_array($settings['enable_profile_tabs'])) {
162 - if (!isset($settings['enable_profile_tabs']['more_info'])) {
163 - $settings['enable_profile_tabs'][] = 'more_info';
215 + foreach ( $options as $option => $value ) {
216 + if ( ! isset( $settings[ $option ] ) ) {
217 + $settings[ $option ] = $value;
164 218 }
165 - if (!isset($settings['enable_profile_tabs']['posts'])) {
166 - $settings['enable_profile_tabs'][] = 'posts';
167 - }
168 - if (!isset($settings['enable_profile_tabs']['comments'])) {
169 - $settings['enable_profile_tabs'][] = 'comments';
170 - }
171 - } else {
172 - $settings['enable_profile_tabs'] = array('more_info', 'posts', 'comments');
173 219 }
174 220
221 + update_option( 'uwp_settings', $settings );
222 + }
175 223
176 - //notifications
177 -
178 - // admin
179 - $registration_success_email_subject_admin = __( 'New account registration', 'userswp' );
180 - $registration_success_email_content_admin = __("A user has been registered recently on your website. [#extras#]", "userswp");
181 -
182 - if (!isset($settings['registration_success_email_subject_admin'])) {
183 - $settings['registration_success_email_subject_admin'] = $registration_success_email_subject_admin;
224 + public static function init_background_updater() {
225 + if ( empty( self::$background_updater ) ) {
226 + include_once __DIR__ . '/class-uwp-background-updater.php';
227 + self::$background_updater = new UsersWP_Background_Updater();
184 228 }
185 - if (!isset($settings['registration_success_email_content_admin'])) {
186 - $settings['registration_success_email_content_admin'] = $registration_success_email_content_admin;
187 - }
229 + }
188 230
231 + /**
232 + * Syncs WP usermeta with UsersWP usermeta during plugin activation.
233 + *
234 + * @since 1.0.0
235 + * @package userswp
236 + * @return void
237 + */
238 + public static function uwp_update_usermeta( $dispatch = false ) {
239 + $update_callback = 'uwp_insert_usermeta';
240 + self::init_background_updater();
189 241
190 - // User
191 -
192 - // Register
193 - $registration_success_email_subject = __('Your Log In Details', 'userswp');
194 - $registration_success_email_content = __("<p>Dear [#user_name#],</p><p>You can log in with the following information:</p>[#login_details#]<p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
195 -
196 - if (!isset($settings['registration_success_email_subject'])) {
197 - $settings['registration_success_email_subject'] = $registration_success_email_subject;
242 + uwp_error_log( sprintf( 'Queuing %s - %s', USERSWP_VERSION, $update_callback ) );
243 + self::$background_updater->push_to_queue( $update_callback );
244 + if ( $dispatch ) {
245 + self::$background_updater->save()->dispatch();
198 246 }
199 - if (!isset($settings['registration_success_email_content'])) {
200 - $settings['registration_success_email_content'] = $registration_success_email_content;
201 - }
202 -
203 - // Activate
204 - $registration_activate_email_subject = __('Please activate your account', 'userswp');
205 - $registration_activate_email_content = __("<p>Dear [#user_name#],</p><p>Thank you for signing up with [#site_name#]</p>[#login_details#]<p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
206 -
207 - if (!isset($settings['registration_activate_email_subject'])) {
208 - $settings['registration_activate_email_subject'] = $registration_activate_email_subject;
209 - }
210 - if (!isset($settings['registration_activate_email_content'])) {
211 - $settings['registration_activate_email_content'] = $registration_activate_email_content;
212 - }
213 -
214 - // Forgot
215 - $forgot_password_email_subject = __('[#site_name#] - Your new password', 'userswp');
216 - $forgot_password_email_content = __("<p>Dear [#user_name#],</p>[#login_details#]<p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
217 -
218 - if (!isset($settings['forgot_password_email_subject'])) {
219 - $settings['forgot_password_email_subject'] = $forgot_password_email_subject;
220 - }
221 - if (!isset($settings['forgot_password_email_content'])) {
222 - $settings['forgot_password_email_content'] = $forgot_password_email_content;
223 - }
224 -
225 - // Change
226 - $change_password_email_subject = __('[#site_name#] - Password has been changed', 'userswp');
227 - $change_password_email_content = __("<p>Dear [#user_name#],</p><p>Your password has been changed successfully.</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
228 -
229 - if (!isset($settings['change_password_email_subject'])) {
230 - $settings['change_password_email_subject'] = $change_password_email_subject;
231 - }
232 - if (!isset($settings['change_password_email_content'])) {
233 - $settings['change_password_email_content'] = $change_password_email_content;
234 - }
235 -
236 - // Reset
237 - $reset_password_email_subject = __('[#site_name#] - Password has been reset', 'userswp');
238 - $reset_password_email_content = __("<p>Dear [#user_name#],</p><p>Your password has been reset</p><p>You can login here: [#login_url#]</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
239 -
240 - if (!isset($settings['reset_password_email_subject'])) {
241 - $settings['reset_password_email_subject'] = $reset_password_email_subject;
242 - }
243 - if (!isset($settings['reset_password_email_content'])) {
244 - $settings['reset_password_email_content'] = $reset_password_email_content;
245 - }
246 -
247 - // Update
248 - $account_update_email_subject = __('[#site_name#] - Account has been updated', 'userswp');
249 - $account_update_email_content = __("<p>Dear [#user_name#],</p><p>Your account has been updated successfully</p><p>Thank you,<br /><br />[#site_name_url#].</p>" ,'userswp');
250 -
251 - if (!isset($settings['account_update_email_subject'])) {
252 - $settings['account_update_email_subject'] = $account_update_email_subject;
253 - }
254 - if (!isset($settings['account_update_email_content'])) {
255 - $settings['account_update_email_content'] = $account_update_email_content;
256 - }
257 -
258 - update_option( 'uwp_settings', $settings );
259 -
260 247 }
261 248
262 249 /**
263 - * Creates tables during plugin activation.
250 + * Get list of DB update callbacks.
264 251 *
265 - * @since 1.0.0
266 - * @package userswp
267 - * @return void
252 + * @since 3.0.0
253 + * @return array
268 254 */
269 - public static function uwp_create_tables()
270 - {
271 - uwp_create_tables();
255 + public static function get_db_update_callbacks() {
256 + return self::$db_updates;
272 257 }
273 258
274 259 /**
275 - * Creates the new tables added in version 1.0.1 during plugin activation.
260 + * Is a DB update needed?
276 261 *
277 - * @since 1.0.0
278 - * @package userswp
279 - * @return void
262 + * @since 2.0.0
263 + * @return boolean
280 264 */
281 - public static function uwp101_create_tables() {
282 - uwp101_create_tables();
265 + private static function needs_db_update() {
266 + $current_db_version = get_option( 'uwp_db_version', null );
267 + $updates = self::get_db_update_callbacks();
268 +
269 + return ! is_null( $current_db_version ) && ! empty( $updates ) && version_compare( $current_db_version, max( array_keys( $updates ) ), '<' );
283 270 }
284 271
285 272 /**
286 - * Syncs WP usermeta with UsersWP usermeta during plugin activation.
273 + * Push all needed DB updates to the queue for processing.
287 274 *
288 - * @since 1.0.0
289 - * @package userswp
290 - * @return void
275 + * @since 2.0.0
291 276 */
292 - public static function uwp_insert_usermeta()
293 - {
294 - global $wpdb;
295 - $sort= "user_registered";
296 - $all_users_id = $wpdb->get_col( $wpdb->prepare(
297 - "SELECT $wpdb->users.ID FROM $wpdb->users ORDER BY %s ASC"
298 - , $sort ));
277 + private static function update() {
278 + $current_db_version = get_option( 'uwp_db_version' );
279 + $update_queued = false;
280 + self::init_background_updater();
281 + foreach ( self::get_db_update_callbacks() as $version => $update_callbacks ) {
282 + if ( version_compare( $current_db_version, $version, '<' ) ) {
283 + foreach ( $update_callbacks as $update_callback ) {
284 + uwp_error_log( sprintf( 'Queuing %s - %s', $version, $update_callback ) );
285 + self::$background_updater->push_to_queue( $update_callback );
286 + $update_queued = true;
287 + }
288 + }
289 + }
299 290
300 - //we got all the IDs, now loop through them to get individual IDs
301 - foreach ( $all_users_id as $user_id ) {
302 - // get user info by calling get_userdata() on each id
303 - $user_data = get_userdata($user_id);
304 - $first_name = get_user_meta( $user_id, 'first_name', true );
305 - $last_name = get_user_meta( $user_id, 'last_name', true );
306 - $bio = get_user_meta( $user_id, 'description', true );
307 - uwp_update_usermeta($user_id, 'uwp_account_username', $user_data->user_login);
308 - uwp_update_usermeta($user_id, 'uwp_account_email', $user_data->user_email);
309 - uwp_update_usermeta($user_id, 'uwp_account_first_name', $first_name);
310 - uwp_update_usermeta($user_id, 'uwp_account_last_name', $last_name);
311 - uwp_update_usermeta($user_id, 'uwp_account_bio', $bio);
312 - uwp_update_usermeta($user_id, 'uwp_account_display_name', $user_data->display_name);
291 + if ( $update_queued ) {
292 + self::uwp_update_usermeta();// make sure to sync user meta
293 + self::$background_updater->save()->dispatch();
294 + } else {
295 + self::uwp_update_usermeta( true );// make sure to sync user meta
313 296 }
314 297 }
315 298
316 299 /**
@@ -319,18 +302,17 @@
319 302 * @since 1.0.0
320 303 * @package userswp
321 304 * @return void
322 305 */
323 - public static function uwp_create_default_fields()
324 - {
306 + public static function create_default_fields() {
325 307 $form_builder = new UsersWP_Form_Builder();
326 308
327 309 $fields = self::uwp_default_custom_fields();
328 310
329 - $fields = apply_filters('uwp_before_default_custom_fields_saved', $fields);
311 + $fields = apply_filters( 'uwp_before_default_custom_fields_saved', $fields );
330 312
331 - foreach ($fields as $field_index => $field) {
332 - $form_builder->uwp_admin_form_field_save($field);
313 + foreach ( $fields as $field_index => $field ) {
314 + $form_builder->admin_form_field_save( $field );
333 315 }
334 316 }
335 317
336 318 /**
@@ -339,9 +321,9 @@
339 321 * @since 1.0.0
340 322 * @package userswp
341 323 * @return array Merged custom fields.
342 324 */
343 - public static function uwp_default_custom_fields(){
325 + public static function uwp_default_custom_fields() {
344 326
345 327 $login = self::uwp_default_custom_fields_login();
346 328 $forgot = self::uwp_default_custom_fields_forgot();
347 329 $avatar = self::uwp_default_custom_fields_avatar();
@@ -349,14 +331,13 @@
349 331 $change = self::uwp_default_custom_fields_change();
350 332 $reset = self::uwp_default_custom_fields_reset();
351 333 $account = self::uwp_default_custom_fields_account();
352 334
353 - $fields = array_merge($login, $forgot, $account, $avatar, $banner, $change, $reset);
335 + $fields = array_merge( $login, $forgot, $account, $avatar, $banner, $change, $reset );
354 336
355 - $fields = apply_filters('uwp_default_custom_fields', $fields);
337 + $fields = apply_filters( 'uwp_default_custom_fields', $fields );
356 338
357 339 return $fields;
358 -
359 340 }
360 341
361 342 /**
362 343 * Returns Login form default custom fields.
@@ -364,39 +345,39 @@
364 345 * @since 1.0.0
365 346 * @package userswp
366 347 * @return array Login form default custom fields.
367 348 */
368 - public static function uwp_default_custom_fields_login(){
349 + public static function uwp_default_custom_fields_login() {
369 350
370 351 $fields = array();
371 352
372 353 $fields[] = array(
373 - 'form_type' => 'login',
374 - 'field_type' => 'text',
375 - 'data_type' => 'XVARCHAR',
376 - 'site_title' => __('Username', 'userswp'),
377 - 'htmlvar_name' => 'username',
354 + 'form_type' => 'login',
355 + 'field_type' => 'text',
356 + 'data_type' => 'XVARCHAR',
357 + 'site_title' => __( 'Username', 'userswp' ),
358 + 'htmlvar_name' => 'username',
378 359 'default_value' => '',
379 360 'option_values' => '',
380 - 'is_default' => '1',
381 - 'is_active' => '1',
382 - 'is_required' => '1'
361 + 'is_default' => '1',
362 + 'is_active' => '1',
363 + 'is_required' => '1',
383 364 );
384 365
385 366 $fields[] = array(
386 - 'form_type' => 'login',
387 - 'field_type' => 'password',
388 - 'data_type' => 'XVARCHAR',
389 - 'site_title' => __('Password', 'userswp'),
390 - 'htmlvar_name' => 'password',
367 + 'form_type' => 'login',
368 + 'field_type' => 'password',
369 + 'data_type' => 'XVARCHAR',
370 + 'site_title' => __( 'Password', 'userswp' ),
371 + 'htmlvar_name' => 'password',
391 372 'default_value' => '',
392 373 'option_values' => '',
393 - 'is_default' => '1',
394 - 'is_active' => '1',
395 - 'is_required' => '1'
374 + 'is_default' => '1',
375 + 'is_active' => '1',
376 + 'is_required' => '1',
396 377 );
397 378
398 - $fields = apply_filters('uwp_default_custom_fields_login', $fields);
379 + $fields = apply_filters( 'uwp_default_custom_fields_login', $fields );
399 380
400 381 return $fields;
401 382 }
402 383
@@ -406,26 +387,26 @@
406 387 * @since 1.0.0
407 388 * @package userswp
408 389 * @return array Forgot form default custom fields.
409 390 */
410 - public static function uwp_default_custom_fields_forgot(){
391 + public static function uwp_default_custom_fields_forgot() {
411 392
412 393 $fields = array();
413 394
414 395 $fields[] = array(
415 - 'form_type' => 'forgot',
416 - 'field_type' => 'email',
417 - 'data_type' => 'XVARCHAR',
418 - 'site_title' => __('Email', 'userswp'),
419 - 'htmlvar_name' => 'email',
396 + 'form_type' => 'forgot',
397 + 'field_type' => 'email',
398 + 'data_type' => 'XVARCHAR',
399 + 'site_title' => __( 'Email', 'userswp' ),
400 + 'htmlvar_name' => 'email',
420 401 'default_value' => '',
421 402 'option_values' => '',
422 - 'is_default' => '1',
423 - 'is_active' => '1',
424 - 'is_required' => '1'
403 + 'is_default' => '1',
404 + 'is_active' => '1',
405 + 'is_required' => '1',
425 406 );
426 407
427 - $fields = apply_filters('uwp_default_custom_fields_forgot', $fields);
408 + $fields = apply_filters( 'uwp_default_custom_fields_forgot', $fields );
428 409
429 410 return $fields;
430 411 }
431 412
@@ -435,35 +416,35 @@
435 416 * @since 1.0.0
436 417 * @package userswp
437 418 * @return array Avatar form default custom fields.
438 419 */
439 - public static function uwp_default_custom_fields_avatar(){
420 + public static function uwp_default_custom_fields_avatar() {
440 421
441 422 $fields = array();
442 423
443 424 $fields[] = array(
444 - 'form_type' => 'avatar',
445 - 'field_type' => 'file',
446 - 'data_type' => 'TEXT',
447 - 'site_title' => __('Avatar', 'userswp'),
448 - 'htmlvar_name' => 'file',
425 + 'form_type' => 'avatar',
426 + 'field_type' => 'file',
427 + 'data_type' => 'TEXT',
428 + 'site_title' => __( 'Avatar', 'userswp' ),
429 + 'htmlvar_name' => 'avatar',
449 430 'default_value' => '',
450 431 'option_values' => '',
451 - 'is_default' => '1',
452 - 'is_active' => '1',
453 - 'is_required' => '1',
454 - 'extra_fields' => array(
455 - 'uwp_file_types' => array(
432 + 'is_default' => '1',
433 + 'is_active' => '1',
434 + 'is_required' => '1',
435 + 'extra_fields' => array(
436 + 'uwp_file_types' => array(
456 437 'jpg',
457 438 'jpe',
458 439 'jpeg',
459 440 'gif',
460 - 'png'
441 + 'png',
461 442 ),
462 - )
443 + ),
463 444 );
464 445
465 - $fields = apply_filters('uwp_default_custom_fields_avatar', $fields);
446 + $fields = apply_filters( 'uwp_default_custom_fields_avatar', $fields );
466 447
467 448 return $fields;
468 449 }
469 450
@@ -473,35 +454,35 @@
473 454 * @since 1.0.0
474 455 * @package userswp
475 456 * @return array Banner form default custom fields.
476 457 */
477 - public static function uwp_default_custom_fields_banner(){
458 + public static function uwp_default_custom_fields_banner() {
478 459
479 460 $fields = array();
480 461
481 462 $fields[] = array(
482 - 'form_type' => 'banner',
483 - 'field_type' => 'file',
484 - 'data_type' => 'TEXT',
485 - 'site_title' => __('Banner', 'userswp'),
486 - 'htmlvar_name' => 'file',
463 + 'form_type' => 'banner',
464 + 'field_type' => 'file',
465 + 'data_type' => 'TEXT',
466 + 'site_title' => __( 'Banner', 'userswp' ),
467 + 'htmlvar_name' => 'banner',
487 468 'default_value' => '',
488 469 'option_values' => '',
489 - 'is_default' => '1',
490 - 'is_active' => '1',
491 - 'is_required' => '1',
492 - 'extra_fields' => array(
493 - 'uwp_file_types' => array(
470 + 'is_default' => '1',
471 + 'is_active' => '1',
472 + 'is_required' => '1',
473 + 'extra_fields' => array(
474 + 'uwp_file_types' => array(
494 475 'jpg',
495 476 'jpe',
496 477 'jpeg',
497 478 'gif',
498 - 'png'
479 + 'png',
499 480 ),
500 - )
481 + ),
501 482 );
502 483
503 - $fields = apply_filters('uwp_default_custom_fields_banner', $fields);
484 + $fields = apply_filters( 'uwp_default_custom_fields_banner', $fields );
504 485
505 486 return $fields;
506 487 }
507 488
@@ -511,52 +492,52 @@
511 492 * @since 1.0.0
512 493 * @package userswp
513 494 * @return array Change Password form default custom fields.
514 495 */
515 - public static function uwp_default_custom_fields_change(){
496 + public static function uwp_default_custom_fields_change() {
516 497
517 498 $fields = array();
518 499
519 500 $fields[] = array(
520 - 'form_type' => 'change',
521 - 'field_type' => 'password',
522 - 'data_type' => 'XVARCHAR',
523 - 'site_title' => __('Old Password', 'userswp'),
524 - 'htmlvar_name' => 'old_password',
501 + 'form_type' => 'change',
502 + 'field_type' => 'password',
503 + 'data_type' => 'XVARCHAR',
504 + 'site_title' => __( 'Old Password', 'userswp' ),
505 + 'htmlvar_name' => 'old_password',
525 506 'default_value' => '',
526 507 'option_values' => '',
527 - 'is_default' => '1',
528 - 'is_active' => '1',
529 - 'is_required' => '1'
508 + 'is_default' => '1',
509 + 'is_active' => '1',
510 + 'is_required' => '1',
530 511 );
531 512
532 513 $fields[] = array(
533 - 'form_type' => 'change',
534 - 'field_type' => 'password',
535 - 'data_type' => 'XVARCHAR',
536 - 'site_title' => __('New Password', 'userswp'),
537 - 'htmlvar_name' => 'password',
514 + 'form_type' => 'change',
515 + 'field_type' => 'password',
516 + 'data_type' => 'XVARCHAR',
517 + 'site_title' => __( 'New Password', 'userswp' ),
518 + 'htmlvar_name' => 'password',
538 519 'default_value' => '',
539 520 'option_values' => '',
540 - 'is_default' => '1',
541 - 'is_active' => '1',
542 - 'is_required' => '1'
521 + 'is_default' => '1',
522 + 'is_active' => '1',
523 + 'is_required' => '1',
543 524 );
544 525
545 526 $fields[] = array(
546 - 'form_type' => 'change',
547 - 'field_type' => 'password',
548 - 'data_type' => 'XVARCHAR',
549 - 'site_title' => __('Confirm Password', 'userswp'),
550 - 'htmlvar_name' => 'confirm_password',
527 + 'form_type' => 'change',
528 + 'field_type' => 'password',
529 + 'data_type' => 'XVARCHAR',
530 + 'site_title' => __( 'Confirm Password', 'userswp' ),
531 + 'htmlvar_name' => 'confirm_password',
551 532 'default_value' => '',
552 533 'option_values' => '',
553 - 'is_default' => '1',
554 - 'is_active' => '1',
555 - 'is_required' => '1'
534 + 'is_default' => '1',
535 + 'is_active' => '1',
536 + 'is_required' => '1',
556 537 );
557 538
558 - $fields = apply_filters('uwp_default_custom_fields_change', $fields);
539 + $fields = apply_filters( 'uwp_default_custom_fields_change', $fields );
559 540
560 541 return $fields;
561 542 }
562 543
@@ -566,39 +547,39 @@
566 547 * @since 1.0.0
567 548 * @package userswp
568 549 * @return array Reset Password form default custom fields.
569 550 */
570 - public static function uwp_default_custom_fields_reset(){
551 + public static function uwp_default_custom_fields_reset() {
571 552
572 553 $fields = array();
573 554
574 555 $fields[] = array(
575 - 'form_type' => 'reset',
576 - 'field_type' => 'password',
577 - 'data_type' => 'XVARCHAR',
578 - 'site_title' => __('Password', 'userswp'),
579 - 'htmlvar_name' => 'password',
556 + 'form_type' => 'reset',
557 + 'field_type' => 'password',
558 + 'data_type' => 'XVARCHAR',
559 + 'site_title' => __( 'Password', 'userswp' ),
560 + 'htmlvar_name' => 'password',
580 561 'default_value' => '',
581 562 'option_values' => '',
582 - 'is_default' => '1',
583 - 'is_active' => '1',
584 - 'is_required' => '1'
563 + 'is_default' => '1',
564 + 'is_active' => '1',
565 + 'is_required' => '1',
585 566 );
586 567
587 568 $fields[] = array(
588 - 'form_type' => 'reset',
589 - 'field_type' => 'password',
590 - 'data_type' => 'XVARCHAR',
591 - 'site_title' => __('Confirm Password', 'userswp'),
592 - 'htmlvar_name' => 'confirm_password',
569 + 'form_type' => 'reset',
570 + 'field_type' => 'password',
571 + 'data_type' => 'XVARCHAR',
572 + 'site_title' => __( 'Confirm Password', 'userswp' ),
573 + 'htmlvar_name' => 'confirm_password',
593 574 'default_value' => '',
594 575 'option_values' => '',
595 - 'is_default' => '1',
596 - 'is_active' => '1',
597 - 'is_required' => '1'
576 + 'is_default' => '1',
577 + 'is_active' => '1',
578 + 'is_required' => '1',
598 579 );
599 580
600 - $fields = apply_filters('uwp_default_custom_fields_reset', $fields);
581 + $fields = apply_filters( 'uwp_default_custom_fields_reset', $fields );
601 582
602 583 return $fields;
603 584 }
604 585
@@ -608,132 +589,128 @@
608 589 * @since 1.0.0
609 590 * @package userswp
610 591 * @return array Account form default custom fields.
611 592 */
612 - public static function uwp_default_custom_fields_account(){
593 + public static function uwp_default_custom_fields_account() {
613 594
614 595 $fields = array();
615 596
616 597 $fields[] = array(
617 - 'form_type' => 'account',
618 - 'field_type' => 'text',
619 - 'data_type' => 'XVARCHAR',
620 - 'site_title' => __('First Name', 'userswp'),
621 - 'htmlvar_name' => 'first_name',
622 - 'default_value' => '',
623 - 'option_values' => '',
624 - 'is_default' => '1',
625 - 'is_public' => '1',
626 - 'is_active' => '1',
627 - 'is_required' => '1',
598 + 'form_type' => 'account',
599 + 'field_type' => 'text',
600 + 'data_type' => 'XVARCHAR',
601 + 'site_title' => __( 'First Name', 'userswp' ),
602 + 'htmlvar_name' => 'first_name',
603 + 'default_value' => '',
604 + 'option_values' => '',
605 + 'is_default' => '1',
606 + 'is_public' => '1',
607 + 'is_active' => '1',
608 + 'is_required' => '1',
628 609 'is_register_field' => '1',
629 - 'is_search_field' => '1',
630 - 'css_class' => 'uwp-half uwp-half-left',
610 + 'is_search_field' => '1',
631 611 );
632 612
633 613 $fields[] = array(
634 - 'form_type' => 'account',
635 - 'field_type' => 'text',
636 - 'data_type' => 'XVARCHAR',
637 - 'site_title' => __('Last Name', 'userswp'),
638 - 'htmlvar_name' => 'last_name',
639 - 'default_value' => '',
640 - 'option_values' => '',
641 - 'is_default' => '1',
642 - 'is_public' => '1',
643 - 'is_active' => '1',
644 - 'is_required' => '1',
614 + 'form_type' => 'account',
615 + 'field_type' => 'text',
616 + 'data_type' => 'XVARCHAR',
617 + 'site_title' => __( 'Last Name', 'userswp' ),
618 + 'htmlvar_name' => 'last_name',
619 + 'default_value' => '',
620 + 'option_values' => '',
621 + 'is_default' => '1',
622 + 'is_public' => '1',
623 + 'is_active' => '1',
624 + 'is_required' => '1',
645 625 'is_register_field' => '1',
646 - 'is_search_field' => '1',
647 - 'css_class' => 'uwp-half uwp-half-right',
626 + 'is_search_field' => '1',
648 627 );
649 628
650 629 $fields[] = array(
651 - 'form_type' => 'account',
652 - 'field_type' => 'text',
653 - 'data_type' => 'XVARCHAR',
654 - 'site_title' => __('Username', 'userswp'),
655 - 'htmlvar_name' => 'username',
656 - 'default_value' => '',
657 - 'option_values' => '',
658 - 'is_default' => '1',
659 - 'is_public' => '1',
660 - 'is_active' => '1',
661 - 'is_required' => '1',
662 - 'is_register_field' => '1',
663 - 'is_search_field' => '1',
630 + 'form_type' => 'account',
631 + 'field_type' => 'text',
632 + 'data_type' => 'XVARCHAR',
633 + 'site_title' => __( 'Username', 'userswp' ),
634 + 'htmlvar_name' => 'username',
635 + 'default_value' => '',
636 + 'option_values' => '',
637 + 'is_default' => '1',
638 + 'is_public' => '1',
639 + 'is_active' => '1',
640 + 'is_required' => '1',
641 + 'is_register_field' => '1',
642 + 'is_search_field' => '1',
664 643 'is_register_only_field' => '1',
665 644 );
666 645
667 646 $fields[] = array(
668 - 'form_type' => 'account',
669 - 'field_type' => 'text',
670 - 'data_type' => 'XVARCHAR',
671 - 'site_title' => __('Display Name', 'userswp'),
672 - 'htmlvar_name' => 'display_name',
673 - 'default_value' => '',
674 - 'option_values' => '',
675 - 'is_default' => '1',
676 - 'is_public' => '1',
677 - 'is_active' => '1',
678 - 'is_required' => '0',
647 + 'form_type' => 'account',
648 + 'field_type' => 'text',
649 + 'data_type' => 'XVARCHAR',
650 + 'site_title' => __( 'Display Name', 'userswp' ),
651 + 'htmlvar_name' => 'display_name',
652 + 'default_value' => '',
653 + 'option_values' => '',
654 + 'is_default' => '1',
655 + 'is_public' => '1',
656 + 'is_active' => '1',
657 + 'is_required' => '0',
679 658 'is_register_field' => '0',
680 - 'is_search_field' => '1',
659 + 'is_search_field' => '1',
681 660 );
682 661
683 662 $fields[] = array(
684 - 'form_type' => 'account',
685 - 'field_type' => 'email',
686 - 'data_type' => 'XVARCHAR',
687 - 'site_title' => __('Email', 'userswp'),
688 - 'htmlvar_name' => 'email',
689 - 'default_value' => '',
690 - 'option_values' => '',
691 - 'is_default' => '1',
692 - 'is_active' => '1',
693 - 'is_required' => '1',
663 + 'form_type' => 'account',
664 + 'field_type' => 'email',
665 + 'data_type' => 'XVARCHAR',
666 + 'site_title' => __( 'Email', 'userswp' ),
667 + 'htmlvar_name' => 'email',
668 + 'default_value' => '',
669 + 'option_values' => '',
670 + 'is_default' => '1',
671 + 'is_active' => '1',
672 + 'is_required' => '1',
694 673 'is_register_field' => '1',
695 - 'is_search_field' => '1',
674 + 'is_search_field' => '1',
696 675 );
697 676
698 -
699 677 $fields[] = array(
700 - 'form_type' => 'account',
701 - 'field_type' => 'textarea',
702 - 'data_type' => 'TEXT',
703 - 'site_title' => __('Bio', 'userswp'),
704 - 'htmlvar_name' => 'bio',
705 - 'default_value' => '',
706 - 'option_values' => '',
707 - 'is_default' => '1',
708 - 'is_active' => '1',
709 - 'is_public' => '1',
710 - 'is_required' => '1',
678 + 'form_type' => 'account',
679 + 'field_type' => 'textarea',
680 + 'data_type' => 'TEXT',
681 + 'site_title' => __( 'Bio', 'userswp' ),
682 + 'htmlvar_name' => 'bio',
683 + 'default_value' => '',
684 + 'option_values' => '',
685 + 'is_default' => '0',
686 + 'is_active' => '1',
687 + 'is_public' => '1',
688 + 'is_required' => '1',
711 689 'is_search_field' => '1',
712 - 'show_in' => array('[profile_side]', '[users]')
690 + 'show_in' => array( '[users]' ),
713 691 );
714 692
715 693 $fields[] = array(
716 - 'form_type' => 'account',
717 - 'field_type' => 'password',
718 - 'data_type' => 'XVARCHAR',
719 - 'site_title' => __('Password', 'userswp'),
720 - 'htmlvar_name' => 'password',
721 - 'default_value' => '',
722 - 'option_values' => '',
723 - 'is_default' => '1',
724 - 'is_active' => '1',
725 - 'is_required' => '1',
726 - 'is_register_field' => '1',
694 + 'form_type' => 'account',
695 + 'field_type' => 'password',
696 + 'data_type' => 'XVARCHAR',
697 + 'site_title' => __( 'Password', 'userswp' ),
698 + 'htmlvar_name' => 'password',
699 + 'default_value' => '',
700 + 'option_values' => '',
701 + 'is_default' => '1',
702 + 'is_active' => '1',
703 + 'is_required' => '1',
704 + 'is_register_field' => '1',
727 705 'is_register_only_field' => '1',
728 - 'extra' => array(
729 - 'confirm_password' => '1'
730 - )
706 + 'extra' => array(
707 + 'confirm_password' => '1',
708 + ),
731 709 );
732 710
711 + $fields = apply_filters( 'uwp_default_custom_fields_account', $fields );
733 712
734 - $fields = apply_filters('uwp_default_custom_fields_account', $fields);
735 -
736 713 return $fields;
737 714 }
738 715
739 716 /**
@@ -742,9 +719,9 @@
742 719 * @since 1.0.0
743 720 * @package userswp
744 721 * @return void
745 722 */
746 - public static function uwp_flush_rewrite_rules() {
723 + public static function flush_rewrite_rules() {
747 724 flush_rewrite_rules();
748 725 }
749 726
750 727 /**
@@ -753,9 +730,9 @@
753 730 * @since 1.0.0
754 731 * @package userswp
755 732 * @return void
756 733 */
757 - public static function uwp_insert_form_extras() {
734 + public static function insert_form_extras( $form_id = 1 ) {
758 735 global $wpdb;
759 736 $extras_table_name = uwp_get_table_prefix() . 'uwp_form_extras';
760 737
761 738 $fields = array();
@@ -760,61 +737,61 @@
760 737
761 738 $fields = array();
762 739
763 740 $fields[] = array(
764 - 'form_type' => 'register',
765 - 'field_type' => 'text',
766 - 'is_default' => '1',
767 - 'htmlvar_name' => 'uwp_account_first_name'
741 + 'form_type' => 'register',
742 + 'field_type' => 'text',
743 + 'is_default' => '0',
744 + 'htmlvar_name' => 'first_name',
768 745 );
769 746
770 747 $fields[] = array(
771 - 'form_type' => 'register',
772 - 'field_type' => 'text',
773 - 'is_default' => '1',
774 - 'htmlvar_name' => 'uwp_account_last_name'
748 + 'form_type' => 'register',
749 + 'field_type' => 'text',
750 + 'is_default' => '0',
751 + 'htmlvar_name' => 'last_name',
775 752 );
776 753
777 754 $fields[] = array(
778 - 'form_type' => 'register',
779 - 'field_type' => 'text',
780 - 'is_default' => '1',
781 - 'htmlvar_name' => 'uwp_account_username'
755 + 'form_type' => 'register',
756 + 'field_type' => 'text',
757 + 'is_default' => '1',
758 + 'htmlvar_name' => 'username',
782 759 );
783 760
784 761 $fields[] = array(
785 - 'form_type' => 'register',
786 - 'field_type' => 'email',
787 - 'is_default' => '1',
788 - 'htmlvar_name' => 'uwp_account_email'
762 + 'form_type' => 'register',
763 + 'field_type' => 'email',
764 + 'is_default' => '1',
765 + 'htmlvar_name' => 'email',
789 766 );
790 767
791 768 $fields[] = array(
792 - 'form_type' => 'register',
793 - 'field_type' => 'password',
794 - 'is_default' => '1',
795 - 'htmlvar_name' => 'uwp_account_password'
769 + 'form_type' => 'register',
770 + 'field_type' => 'password',
771 + 'is_default' => '0',
772 + 'htmlvar_name' => 'password',
796 773 );
797 774
798 -
799 - foreach ($fields as $field) {
800 - $last_order = $wpdb->get_var("SELECT MAX(sort_order) as last_order FROM " . $extras_table_name);
775 + foreach ( $fields as $field ) {
776 + $last_order = $wpdb->get_var( 'SELECT MAX(sort_order) as last_order FROM ' . $extras_table_name . ' where form_id = ' . $form_id );
801 777 $sort_order = (int)$last_order + 1;
802 778 $wpdb->query(
803 779 $wpdb->prepare(
804 -
805 - "insert into " . $extras_table_name . " set
780 + 'insert into ' . $extras_table_name . ' set
806 781 form_type = %s,
807 782 field_type = %s,
808 783 is_default = %s,
809 784 site_htmlvar_name = %s,
810 - sort_order = %s",
785 + sort_order = %s,
786 + form_id = %s',
811 787 array(
812 788 $field['form_type'],
813 789 $field['field_type'],
814 790 $field['is_default'],
815 791 $field['htmlvar_name'],
816 - $sort_order
792 + $sort_order,
793 + $form_id,
817 794 )
818 795 )
819 796 );
820 797 }
@@ -819,5 +796,66 @@
819 796 );
820 797 }
821 798 }
822 799
823 -}
800 + /**
801 + * Performs automatic upgrade
802 + *
803 + * @since 2.0.0
804 + * @package userswp
805 + * @return void
806 + */
807 + public static function automatic_upgrade() {
808 + $uwp_db_version = get_option( 'uwp_db_version' );
809 +
810 + if ( $uwp_db_version != USERSWP_VERSION ) {
811 + self::activate( is_plugin_active_for_network( 'userswp/userswp.php' ) );
812 + $settings = get_option( 'uwp_settings', array() );
813 + $needs_update = false;
814 + if ( isset( $settings['design_style'] ) && 'bootstrap' == $settings['design_style'] ) {
815 + $settings['users_default_layout'] = '3col';
816 + $needs_update = true;
817 + }
818 +
819 + if ( isset( $settings['uwp_registration_action'] ) && $settings['uwp_registration_action'] == 'force_redirect' ) {
820 + $settings['uwp_registration_action'] = 'auto_approve_login';
821 + $needs_update = true;
822 + }
823 +
824 + $get_register_form = isset( $settings['multiple_registration_forms'] ) ? $settings['multiple_registration_forms'] : false;
825 +
826 + if ( ! empty( $get_register_form ) && is_array( $get_register_form ) ) {
827 +
828 + foreach ( $get_register_form as $key => $register_form ) {
829 +
830 + if ( ! empty( $register_form['id'] ) ) {
831 +
832 + $reg_action = isset( $register_form['reg_action'] ) ? $register_form['reg_action'] : '';
833 +
834 + if ( isset( $reg_action ) && $reg_action == 'force_redirect' ) {
835 + $settings['multiple_registration_forms'][ $key ]['reg_action'] = 'auto_approve_login';
836 + $needs_update = true;
837 + }
838 +
839 + $reg_title = isset( $register_form['title'] ) ? $register_form['title'] : '';
840 +
841 + if ( isset( $reg_title ) && ! empty( $reg_title ) ) {
842 + $clean_title = sanitize_text_field( $reg_title );
843 + if ( $clean_title !== $reg_title ) {
844 + $settings['multiple_registration_forms'][ $key ]['title'] = $clean_title;
845 + $needs_update = true;
846 + }
847 + }
848 + }
849 + }
850 + }
851 +
852 + if ( $needs_update ) {
853 + update_option( 'uwp_settings', $settings );
854 + }
855 +
856 + // Run this function once.
857 + update_option( 'uwp_db_version', USERSWP_VERSION );
858 +
859 + }
860 + }
861 +}