its-webhosting / umich-oidc-login

WordPress plugin for restricting access to the whole site or only certain parts based on OIDC login and group membership information
GNU General Public License v3.0
6 stars 4 forks source link

Advanced Custom Fields throws an Error #9

Open mrdonduck opened 3 months ago

mrdonduck commented 3 months ago

When using custom fields in other custom post types and then proceeding to save the post produces the following error: Updating failed. Sorry, you are not allowed to edit the _umich_oidc_access custom field.

markmont commented 3 months ago

Hi, Don! Thanks for reporting this. This is a problem we already knew about but we have not had time to look into it yet. It will be fixed, but I don’t have a specific date. We welcome all contributions to the plugin, but to escalate this, send an email to webmaster@umich.edu.

— Mark Montague, Manager, University of Michigan ITS Web Hosting

matt-smiarowski commented 1 week ago

Hi Mark,

I wanted to chime in on this issue, as we're getting this error too. However, we are not using Advanced Custom Fields. This error is being thrown for us when creating new Reusable Blocks (or Patterns as they are called now). We only get this error when creating a new Reusable Block, editing existing content is ok.

andyguzman commented 21 hours ago

I'm working on a fork that might help solve this. We haven't encountered the exact issues noted above yet but I have a feeling they are related.

The plugin is currently only set up to add the permissions metabox to the Post and Page post types. The js for the metabox, however, is enqueued for post.php or post-new.php which is used across a lot of different interfaces in Wordpress. I'm guessing it is trying to save a meta value that doesn't exist on non post/page post types and throwing the error you're seeing.

My main goal was to try and make the metabox available to custom post types and fix an issue on post types we aren't using Gutenberg on. I added a new option to the OIDC settings page that lets you select from your custom post types, making the metabox available on their edit pages. I also made a modification to the js so it doesn't try to render the metabox on post types you haven't selected. That should hopefully prevent the error, particularly on some of those built in Gutenberg based pattern / block types which I have excluded by default.

If either of you have a test environment (probably not quite production ready) where you can check if this helps please give it a try and let me know if you get better results. I've only been poking at it a couple of days and it seems to be working for the main purpose my changes intended, but I'd be curious if it helps with this issue as well.

@markmont If this is looking good to you I can submit a pull request when it is ready if you want to incorporate it into the plugin.