Skip to content

Commit

Permalink
Merge pull request #2678 from QuizandSurveyMaster/dev-zubair
Browse files Browse the repository at this point in the history
fixed fatal error with user role
  • Loading branch information
zubairraeen authored Oct 15, 2024
2 parents 2d5ba00 + 34d3b5d commit 04984ad
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 04984ad

Please sign in to comment.