I have the following Switch statement and it keeps returning "Notice: Undefined variable BB".
The variable is set and I can't work out what's wrong.
This is the first time I've studied switch and am a bit lost here, and any help will be welcome.
if ($user_has_access){
foreach( $user_has_access as $post){
if ( in_array( $current_post_id, (array) $user_has_access )) {
$bbb = 'page_member_page_id_in_user_profile_true';
} elseif ( !in_array( $current_post_id, (array) $user_has_access )) {
$bbb = 'page_member_page_id_in_user_profile_false';
}
}
}
switch ($bbb) :
case "page_member_page_id_in_user_profile_true":
echo "page_member_page_id_in_user_profile_true";
break;
case "page_member_page_id_in_user_profile_false":
echo "page_member_page_id_in_user_profile_false";
break;
default:
echo "Default hasUserProfileAccess";
break;
endswitch;
}