When we update a user in the admin (wp-admin/user-edit.php?user_id=1234) and there is a error on the form (example: username is empty and required) the url change to (wp-admin/user-edit.php) and your plugin trigger a die() in (class-devices.php -> custom_user_profile_fields)because there is no $_GET['user_id'] and prevent page to fully load.
Why not using the $profileuser param for getting the user_id ?
// If is current user's profile (profile.php). if ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) { $user_id = get_current_user_id(); } elseif( ! empty( $profileuser->ID ) ) { $user_id = absint( $profileuser->ID ); // phpcs:ignore } elseif ( ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) { // phpcs:ignore // If is another user's profile page. $user_id = absint( $_GET['user_id'] ); // phpcs:ignore } else { // Otherwise something is wrong. die( 'No user id defined.' ); }
When we update a user in the admin (wp-admin/user-edit.php?user_id=1234) and there is a error on the form (example: username is empty and required) the url change to (wp-admin/user-edit.php) and your plugin trigger a die() in (class-devices.php -> custom_user_profile_fields)because there is no $_GET['user_id'] and prevent page to fully load. Why not using the $profileuser param for getting the user_id ?
// If is current user's profile (profile.php). if ( defined( 'IS_PROFILE_PAGE' ) && IS_PROFILE_PAGE ) { $user_id = get_current_user_id(); } elseif( ! empty( $profileuser->ID ) ) { $user_id = absint( $profileuser->ID ); // phpcs:ignore } elseif ( ! empty( $_GET['user_id'] ) && is_numeric( $_GET['user_id'] ) ) { // phpcs:ignore // If is another user's profile page. $user_id = absint( $_GET['user_id'] ); // phpcs:ignore } else { // Otherwise something is wrong. die( 'No user id defined.' ); }