diff --git a/mlw_quizmaster2.php b/mlw_quizmaster2.php index ce63fc21..d3ed9218 100644 --- a/mlw_quizmaster2.php +++ b/mlw_quizmaster2.php @@ -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 ) ) {