I am trying to: I building a custom menu that fills its sub page automatically. I need check in walker if user is a member of member-group. I get all access group but when i get the options it returns and empty array
$userId = get_current_user_id();
$hasAccess = true;
$access_group = get_post_meta($item->ID, '_wpcf_access_group', true);
if($access_group){
$access_option = get_option('wpcf-access-types', array());
$permitted_group_users = $access_option[ $access_group ]['permissions']['read']['users'];
$hasAccess = in_array( $userId, $permitted_group_users ) ? true : false;
}
I visited this URL:
I expected to see: hasAccess should be true
Instead, I got: Error NOTICE: UNDEFINED INDEX: WPCF-CUSTOM-GROUP-MEMBER-GROUP IN
Dear Salmon,
Please try this, replace this line from:
$access_option = get_option('wpcf-access-types', array());
To:
$model = TAccess_Loader::get('MODEL/Access');
$access_option = $model->getAccessTypes();
And test again
Hi,
Thanks for getting back to me. I tried to change the two lines but the class is not found.
FATAL ERROR: CLASS 'ROOTS\SAGE\EXTRAS\TACCESS_LOADER' NOT FOUND IN
Cheers
Olaf
Hi,
Actually fixed the previous issue. Did not realised I was in wrong namespace. However, I am getting an issue with this line.
$permitted_group_users = $access_option[$access_group]['permissions']['read'];
I checked the $access_group and it it is the right one but it gives my : UNDEFINED INDEX. Below works.
$permitted_group_users = $access_option['wpcf-custom-group-member-group']['permissions']['read'];
Cheers
Olaf
Since it is a custom PHP codes problem, I suggest you debug your codes line by line manually, for example, this line:
$access_group = get_post_meta($item->ID, '_wpcf_access_group', true);
print the result of $access_group, check if it has been setup in right value.
If you needs more assistance for it, please duplicate same problem in a test site, and provide the FTP access and credentials, also point out the problem page URL and where I can edit your PHP codes, I need to debug it in a live website. thanks