PluginProbe
Timetics – Appointment Booking Calendar & Scheduling / 1.0.38
Timetics – Appointment Booking Calendar & Scheduling v1.0.38
1.0.62 1.0.63 1.0.61 1.0.60 1.0.59 1.0.58 1.0.57 1.0.56 trunk 1.0.0 1.0.1 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.2 1.0.20 1.0.21 1.0.22 All 64 releases
← All changes | core/staffs/staff.php +8 -11 1.0.62 → 1.0.38 View file →
@@ -331,13 +331,12 @@
331 331 }
332 332
333 333 $user = get_user_by( 'email', $email );
334 334
335 - // An existing account with this email is a conflict, not an instruction
336 - // to promote it — silently granting the staff role let a caller take
337 - // over any account by submitting its email.
338 - if ( $user ) {
339 - return new \WP_Error( 'timetics_staff_email_exists', __( 'A user with this email address already exists.', 'timetics' ) );
335 + if ( $user && ! in_array( 'timetics-staff', $user->roles, true ) ) {
336 + $user->add_role( 'timetics-staff' );
337 +
338 + return $user->ID;
340 339 }
341 340
342 341 $user_id = wp_insert_user( $args );
343 342
@@ -368,14 +367,12 @@
368 367 }
369 368
370 369 $user_data = get_user_by( 'email', $email );
371 370
372 - // Only a conflict if it belongs to someone other than the staff member
373 - // being edited — otherwise every update where they keep their own
374 - // email would (incorrectly) hit this branch. See create() for why a
375 - // match must never silently grant the staff role.
376 - if ( $user_data && (int) $user_data->ID !== (int) $this->id ) {
377 - return new \WP_Error( 'timetics_staff_email_exists', __( 'A user with this email address already exists.', 'timetics' ) );
371 + if ( $user_data && ! in_array( 'timetics-staff', $user_data->roles, true ) ) {
372 + $user_data->add_role( 'timetics-staff' );
373 +
374 + return $user_data->ID;
378 375 }
379 376
380 377 $updated = wp_update_user( $user );
381 378