caseproof / members

Members WordPress plugin.
GNU General Public License v2.0
80 stars 35 forks source link

PHP Fatal Error when role has no capabilities #69

Open likestor opened 2 years ago

likestor commented 2 years ago

Hello, thank you for your Plugin! I figured out, that php runs in a fatal error in backend, when a user role has no capabilities. In this case throws function array_filter in /wp-includes/class-wp-user-query.php row 452 a fatal error because $role_data['capabilities'] is NULL instead of an array. I hotfixed it for me by changing the line into $role_caps = is_array($role_data['capabilities']) ? array_keys( array_filter( $role_data['capabilities'] ) ) : []; Perhaps there is a way to return an empty array for $role_data['capabilities'] instead of NULL in this case? Thank you and best regards, likestor

DumahX commented 1 year ago

Hi @likestor,

Thank you for bringing this to our attention. I tried replicating the issue on the latest version of the Members plugin by creating a user role with no capabilities assigned to it, then I created a test user who had only this role. When signed in as the user, I was able to access the site (both the front end and WP dashboard) without receiving the error.

Is this error something you're still experiencing? If so, could you please provide me with the steps you're going through so I may see about replicating it on my side?

Kind regards, Tyler