{"id":18904118,"date":"2026-05-11T00:53:32","date_gmt":"2026-05-11T00:53:32","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/undefined-variable-error-24\/"},"modified":"2026-05-11T00:53:32","modified_gmt":"2026-05-11T00:53:32","slug":"undefined-variable-error-24","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/undefined-variable-error-24\/","title":{"rendered":"Undefined variable error"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi Pierre,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For users who login to a site but have no role for the site, an undefined variable error occurs.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\/wp-content\/plugins\/sessions\/includes\/system\/class-session.php:812<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">An empty $roles array should be declared at the start of the function and unless you also insert an additional check here, get_privileges_for_roles() will need to deal with the possibility of receiving an empty array as a variable.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s probably an edge case but I have clients who set users to &#8220;No role for this site&#8221; in order to retain accounts and deny access to member content until subscriptions are renewed.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Cheers,<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">James<\/p>\n","protected":false},"template":"","class_list":["post-18904118","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18904118","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/18904118\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=18904118"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}