Home › Forums › Add-ons › Options Page › 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.
get_field('____', 'options'); call returning something it shouldn’t or is something else happening on the page?
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() https://developer.wordpress.org/reference/functions/get_option/. The option name will be
That worked perfectly! I had forgot that the ACF options items were stored in the wp_options table.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
❓Ever wondered when and why ACF uses JSON instead of the database? Check out our summary of the most recent session of ACF Chat Friday for the answer, and make sure to register for the next session.— Advanced Custom Fields (@wp_acf) February 23, 2023
© 2023 Advanced Custom Fields.