Use of $user_can_edit causes incompatibility with WP User Profiles plugin
Hey maintainer friends! A user of one of my plugins identified a mild incompatibility with this one, and I'd like to provide some context and a recommended code change.
Message
See: https://github.com/stuttter/wp-user-profiles/discussions/60#discussioncomment-527348
Context
WP User Profiles completely replaces the "Edit" experience of editing a user. Think of it like Gutenberg for editing users!
To work, my plugin has to jump through some hoops like Gutenberg does. One of those hoops means that all of the variables inside of WordPress user-edit.php that are actually globals, are not really global anymore in my plugin.
I have made a special consideration for $user_id, but some variables like $title, $sessions, $user_roles, $blogs, $languages, and $errors I am reluctant to explicitly define as globals everywhere in my plugin when they are not needed in it as globals (though they are used inside of their respective methods).
Problem
The Classic Editor plugin uses the $user_can_edit global variable from user-edit.php to determine whether or not to show the per-user "Default Editor" profile option. Because this global is not defined in my plugin, this profile option never appears when using it.
Recommended Solution
I'm thinking that using the global in the Classic Editor plugin might not be a good idea for plugin compatibility reasons like this one. Any global variable can simply be overwritten by any plugin for any reason on this page, triggering this problem.
If the Classic Editor plugin did its own internal capability checks, this specific incompatibility (and maybe any other potential ones) could be avoided.
Here is where that global is defined in WordPress core, if you'd like to copy that behavior into the Classic Editor plugin.
https://github.com/WordPress/WordPress/blob/87a410183417cbe298dd8dd6d758010c63538226/wp-admin/user-edit.php#L77
Looking at PRs and commits here, I may just fix this in the WP User Profiles plugin.
No activity in 2 years. 🤕
If the class method get_classic_settings() was made public the settings fields would not need to be repeated outside Classic Editor (DRY).
Looking at PRs and commits here, I may just fix this in the WP User Profiles plugin.
Ughhh, sorry @JJJ, completely missed this at the time (think I was away/sick?) :(