Completed
Pull Request — develop (#843)
by Zack
05:10
created
includes/extensions/edit-entry/class-edit-entry-user-registration.php 1 patch
Spacing   +27 added lines, -27 removed lines patch added patch discarded remove patch
@@ -52,9 +52,9 @@  discard block
 block discarded – undo
52 52
 	     * @since 1.11
53 53
 	     * @param boolean $boolean Whether to trigger update on user registration (default: true)
54 54
 	     */
55
-	    if( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
55
+	    if ( apply_filters( 'gravityview/edit_entry/user_registration/trigger_update', true ) ) {
56 56
 
57
-	    	add_action( 'gravityview/edit_entry/after_update' , array( $this, 'update_user' ), 10, 2 );
57
+	    	add_action( 'gravityview/edit_entry/after_update', array( $this, 'update_user' ), 10, 2 );
58 58
 
59 59
 		    // last resort in case the current user display name don't match any of the defaults
60 60
 		    add_action( 'gform_user_updated', array( $this, 'restore_display_name' ), 10, 4 );
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
      */
73 73
     public function update_user( $form = array(), $entry_id = 0 ) {
74 74
 
75
-        if( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) {
75
+        if ( ! class_exists( 'GFAPI' ) || ! class_exists( 'GF_User_Registration' ) ) {
76 76
 	        do_action( 'gravityview_log_error', __METHOD__ . ': GFAPI or User Registration class not found; not updating the user' );
77 77
 	        return;
78
-        } elseif( empty( $entry_id ) ) {
78
+        } elseif ( empty( $entry_id ) ) {
79 79
         	do_action( 'gravityview_log_error', __METHOD__ . ': Entry ID is empty; not updating the user', $entry_id );
80 80
 	        return;
81 81
         }
@@ -101,8 +101,8 @@  discard block
 block discarded – undo
101 101
 	    }
102 102
 
103 103
 	    // If an Update feed, make sure the conditions are met.
104
-	    if( rgars( $config, 'meta/feedType' ) === 'update' ) {
105
-	    	if( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
104
+	    if ( rgars( $config, 'meta/feedType' ) === 'update' ) {
105
+	    	if ( ! $gf_user_registration->is_feed_condition_met( $config, $form, $entry ) ) {
106 106
 			    return;
107 107
 		    }
108 108
 	    }
@@ -149,17 +149,17 @@  discard block
 block discarded – undo
149 149
 	     */
150 150
 	    $preserve_role = apply_filters( 'gravityview/edit_entry/user_registration/preserve_role', true, $config, $form, $entry );
151 151
 
152
-	    if( $preserve_role ) {
153
-		    $config['meta']['role'] = 'gfur_preserve_role';
152
+	    if ( $preserve_role ) {
153
+		    $config[ 'meta' ][ 'role' ] = 'gfur_preserve_role';
154 154
 	    }
155 155
 
156
-	    $displayname = $this->match_current_display_name( $entry['created_by'] );
156
+	    $displayname = $this->match_current_display_name( $entry[ 'created_by' ] );
157 157
 
158 158
 	    /**
159 159
 	     * Make sure the current display name is not changed with the update user method.
160 160
 	     * @since 1.15
161 161
 	     */
162
-	    $config['meta']['displayname'] = $displayname ? $displayname : $config['meta']['displayname'];
162
+	    $config[ 'meta' ][ 'displayname' ] = $displayname ? $displayname : $config[ 'meta' ][ 'displayname' ];
163 163
 
164 164
 	    /**
165 165
 	     * @filter `gravityview/edit_entry/user_registration/config` Modify the User Registration Addon feed configuration
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
 
187 187
         $user = get_userdata( $user_id );
188 188
 
189
-        if( ! $user ) {
189
+        if ( ! $user ) {
190 190
         	return false;
191 191
         }
192 192
 
@@ -198,7 +198,7 @@  discard block
 block discarded – undo
198 198
          * In case we can't find the current display name format, trigger last resort method at the 'gform_user_updated' hook
199 199
          * @see restore_display_name
200 200
          */
201
-        if( false === $format ) {
201
+        if ( false === $format ) {
202 202
             $this->_user_before_update = $user;
203 203
         }
204 204
 
@@ -216,20 +216,20 @@  discard block
 block discarded – undo
216 216
     public function generate_display_names( $profileuser ) {
217 217
 
218 218
         $public_display = array();
219
-        $public_display['nickname']  = $profileuser->nickname;
220
-        $public_display['username']  = $profileuser->user_login;
219
+        $public_display[ 'nickname' ]  = $profileuser->nickname;
220
+        $public_display[ 'username' ]  = $profileuser->user_login;
221 221
 
222
-        if ( !empty($profileuser->first_name) ) {
223
-	        $public_display['firstname'] = $profileuser->first_name;
222
+        if ( ! empty( $profileuser->first_name ) ) {
223
+	        $public_display[ 'firstname' ] = $profileuser->first_name;
224 224
         }
225 225
 
226
-        if ( !empty($profileuser->last_name) ) {
227
-	        $public_display['lastname'] = $profileuser->last_name;
226
+        if ( ! empty( $profileuser->last_name ) ) {
227
+	        $public_display[ 'lastname' ] = $profileuser->last_name;
228 228
         }
229 229
 
230
-        if ( !empty($profileuser->first_name) && !empty($profileuser->last_name) ) {
231
-            $public_display['firstlast'] = $profileuser->first_name . ' ' . $profileuser->last_name;
232
-            $public_display['lastfirst'] = $profileuser->last_name . ' ' . $profileuser->first_name;
230
+        if ( ! empty( $profileuser->first_name ) && ! empty( $profileuser->last_name ) ) {
231
+            $public_display[ 'firstlast' ] = $profileuser->first_name . ' ' . $profileuser->last_name;
232
+            $public_display[ 'lastfirst' ] = $profileuser->last_name . ' ' . $profileuser->first_name;
233 233
         }
234 234
 
235 235
         $public_display = array_map( 'trim', $public_display );
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
          */
260 260
         $restore_display_name = apply_filters( 'gravityview/edit_entry/restore_display_name', true );
261 261
 
262
-        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type') === 'update' );
262
+        $is_update_feed = ( $config && rgars( $config, 'meta/feed_type' ) === 'update' );
263 263
 
264 264
         /**
265 265
          * Don't restore display name:
@@ -268,7 +268,7 @@  discard block
 block discarded – undo
268 268
          *   - or we don't need as we found the correct format before updating user.
269 269
          * @since 1.14.4
270 270
          */
271
-        if( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
271
+        if ( ! $restore_display_name || $is_update_feed || is_null( $this->_user_before_update ) ) {
272 272
             return null;
273 273
         }
274 274
 
@@ -276,7 +276,7 @@  discard block
 block discarded – undo
276 276
 
277 277
         // User not found
278 278
 	    if ( ! $user_after_update ) {
279
-	    	do_action('gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) );
279
+	    	do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - User not found at $user_id #%d', $user_id ) );
280 280
 		    return false;
281 281
 	    }
282 282
 
@@ -300,10 +300,10 @@  discard block
 block discarded – undo
300 300
 
301 301
         $updated = wp_update_user( $restored_user );
302 302
 
303
-        if( is_wp_error( $updated ) ) {
304
-            do_action('gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
303
+        if ( is_wp_error( $updated ) ) {
304
+            do_action( 'gravityview_log_error', __METHOD__ . sprintf( ' - There was an error updating user #%d details', $user_id ), $updated );
305 305
         } else {
306
-            do_action('gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
306
+            do_action( 'gravityview_log_debug', __METHOD__ . sprintf( ' - User #%d details restored', $user_id ) );
307 307
         }
308 308
 
309 309
         $this->_user_before_update = null;
Please login to merge, or discard this patch.