Home Forums Add-ons Options Page Get Options Field Breaking Permissions


Get Options Field Breaking Permissions

  • I’m having an issue with ACF and another Plugin User Access Manager (UAM). UAM is a plugin that lets you create user groups based on roles where you can restrict content to be viewable/editable by certain groups. E.g. Half my pages could be only editable to Group A while Group B could only edit pages marked for Group B. This is probably one of those things where ACF will tell me to check with UAM and UAM will tell me to check with ACF so here goes anyway.

    I’m using ACP Pro to create an options page via acf_add_options_page(). I’m using this for a bunch of options throughout my theme, but the main one I’m having an issue with is to turn on or off CPTs in the admin menu. I have a set of checkboxes for the different CPTs that a user can turn on or off.

    Whenever I try to use get_field(‘my_options_page_variable’, ‘option’) in the admin_menu action it breaks some of the permissions put in place by the UAM plugin. If I comment it out this line the UAM stuff works fine. I’ve used the get_field(‘____’, ‘option’) in other actions without issue like add_action(‘wp_head’, ‘_____’).

    Does anyone know if ACF’s get_field(‘____’, ‘options’) invokes or add some sort of permissions level on the current user that could be causing the conflict?

  • I’m not exactly sure by reading your post what the problem is.

    Is the get_field('____', 'options'); call returning something it shouldn’t or is something else happening on the page?

  • The get_field('_____', 'options'); call is returning the correct information. However, the problem is when I use that call in an action, like admin_menu, it’s breaking the functionality of another plugin. The other plugin is called User Access Manager (which has to do with custom permissions, etc). It break’s some of that plugins permissions. If I comment out the get_field('_____', 'options'); it’s fine, if I leave it in, some of the permissions for other users get screwed up.

    I currently have 'capability' => 'edit_theme_options' for the acf_add_options_page array value. I’ve tried lowering the capability something like ‘edit_posts’ and it still has the same effect.

  • I’m not familiar with the other plugin. Generally, when I have problems like this I resort to using WP functions instead of ACF functions. You can get the values form ACF options page field by using get_option() The option name will be "options_{$field_name}"

  • That worked perfectly! I had forgot that the ACF options items were stored in the wp_options table.

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Get Options Field Breaking Permissions’ is closed to new replies.