Skip Navigation

[Resolved] $access_option = get_option('wpcf-access-types', array()); an empty array

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 8 years ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 4 replies, has 2 voices.

Last updated by Luo Yang 8 years ago.

Assisted by: Luo Yang.

Author
Posts
#452809

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

#453292

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

#454172

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

#454573

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

#454721

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

The forum ‘Types Community Support’ is closed to new topics and replies.