Skip to content

Commit

Permalink
fixed fatal error with user role
Browse files Browse the repository at this point in the history
  • Loading branch information
zubairraeen committed Oct 15, 2024
1 parent 553cb97 commit 34d3b5d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions mlw_quizmaster2.php
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,15 @@ public function qsm_add_user_capabilities() {
);

$user = wp_get_current_user();
if ( empty( $user->roles ) || ! is_array( $user->roles ) ) {
return;
}
$roles = (array) $user->roles;
$rolename = $roles[0];

$role = get_role( $rolename );

if ( ! $role ) {
return;
}
// Remove all capabilities first.
foreach ( $administrator_capabilities as $cap ) {
if ( $role->has_cap( $cap ) ) {
Expand Down

0 comments on commit 34d3b5d

Please sign in to comment.