diff --git a/classes/update/class-update-1100.php b/classes/update/class-update-1100.php new file mode 100644 index 0000000000..d21a1503f4 --- /dev/null +++ b/classes/update/class-update-1100.php @@ -0,0 +1,50 @@ +delete_redirect_on_login_user_meta(); + } + + /** + * Delete the prpl_redirect_on_login user meta for all users. + * + * The settings page that allowed users to set their login destination + * has been removed. This migration deletes the user meta to prevent + * users from being redirected to Progress Planner after login. + * + * @return void + */ + private function delete_redirect_on_login_user_meta() { + global $wpdb; + + // Delete the user meta for all users directly from the database. + // This is more efficient than looping through all users. + $wpdb->delete( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching + $wpdb->usermeta, // @phpstan-ignore-line property.nonObject + [ 'meta_key' => 'prpl_redirect_on_login' ], // phpcs:ignore WordPress.DB.SlowDBQuery.slow_db_query_meta_key + [ '%s' ] + ); + } +}