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

PHP Warning: Undefined variable $user in class-guest-contributor-role.php on line 271 #3654

Open
ronchambers opened this issue Dec 31, 2024 · 1 comment
Assignees

Comments

@ronchambers
Copy link
Collaborator

ronchambers commented Dec 31, 2024

Describe the bug

On line 271 ( link ) the variable $user is undefined. I assume it should be $user_or_name->user_login.

From debug.log:

PHP Warning:  Undefined variable $user in /includes/plugins/co-authors-plus/class-guest-contributor-role.php on line 271
PHP Warning:  Attempt to read property "user_login" on null in /includes/plugins/co-authors-plus/class-guest-contributor-role.php on line 271

I would have done a pull request, but I wasn't sure if wrapping the code in is_object() would make sense and then making the string version the default return value. Or possibly keeping is_string and adding is_object, then returning a random string if neither.

To Reproduce
Steps to reproduce the behavior:

  1. Go to /wp-admin/user-new.php
  2. Choose "Guest Contributor" in the "Role" drop down.
  3. Add user with just a "Display Name", all other fields blank.
  4. View warning in debug.log.
  5. View db wp_users.user_email and see that the email is blank. (I'm not sure if this is OK or not).

Expected behavior
There should be no error in debug.log.

@ronchambers
Copy link
Collaborator Author

@leogermani @adekbadek - If you'd like me to fix, let me know :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants