Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use of $user_can_edit causes incompatibility with WP User Profiles plugin #158

Closed
JJJ opened this issue Mar 26, 2021 · 4 comments
Closed

Comments

@JJJ
Copy link

JJJ commented Mar 26, 2021

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: stuttter/wp-user-profiles#60 (comment)

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.

@JJJ
Copy link
Author

JJJ commented Mar 26, 2021

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

@JJJ
Copy link
Author

JJJ commented Mar 26, 2021

Looking at PRs and commits here, I may just fix this in the WP User Profiles plugin.

No activity in 2 years. 🤕

@knutsp
Copy link

knutsp commented Mar 26, 2021

If the class method get_classic_settings() was made public the settings fields would not need to be repeated outside Classic Editor (DRY).

@azaozz
Copy link
Contributor

azaozz commented May 10, 2024

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?) :(

@azaozz azaozz closed this as completed May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants