Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not working for options pages #56

Closed
ethanclevenger91 opened this issue Jul 21, 2016 · 7 comments
Closed

Not working for options pages #56

ethanclevenger91 opened this issue Jul 21, 2016 · 7 comments
Labels

Comments

@ethanclevenger91
Copy link

ethanclevenger91 commented Jul 21, 2016

I wasn't able to post updates to options pages using the latest ACF PRO. I did some digging and come across a couple of potential problems, but I don't claim to know exactly how your plugin works.

1 - I see you're attempting to use option as the post_id argument to acf_get_field_groups, but this doesn't return any fields. I found that a successful call to that function for an options page looks like this:

array (size=18)
  'post_id' => int 0
  'post_type' => int 0
  'page_template' => int 0
  'page_parent' => int 0
  'page_type' => int 0
  'post_status' => int 0
  'post_format' => int 0
  'post_taxonomy' => null
  'taxonomy' => int 0
  'user_id' => int 0
  'user_role' => int 0
  'user_form' => int 0
  'attachment' => int 0
  'comment' => int 0
  'widget' => int 0
  'lang' => string '' (length=0)
  'ajax' => boolean false
  'options_page' => string 'site-general-settings' (length=21)

With the registered options page slug there at the end.

2 - It looks like the ACF Pro Options extension isn't even loaded when the API request is made. I put a die in the constructor for the acf_pro_options_page class and it never fired while making an API request. This means that when it attempts to validate the field, it doesn't find it, unless you're doing something special on your end to bootstrap that.

That's what I found, but maybe it's way off base and I totally misunderstand what's happening. Anyway, moral of the story is I can't currently update any ACF options with this plugin. Let me know if you have thoughts.

Thanks!

@kristoferblack
Copy link

kristoferblack commented Jul 22, 2016

Yeah, options page isn't working for me either.

I just get:

{ code: "rest_no_route", message: "No route was found matching the URL and request method", data: { status: 404 } }

@airesvsg
Copy link
Owner

Hi @ethanclevenger91 and @Specik,
I'll test this.

Thanks

@airesvsg
Copy link
Owner

airesvsg commented Jul 27, 2016

I tested and didn't see any problem. I recorded a video with the test, follow the link:

https://www.youtube.com/watch?v=EPZOxi2QzAI

Thanks

@ethanclevenger91
Copy link
Author

Your example shows a GET request, which does indeed work for me, but I'm getting the same error as @Specik when trying to POST data

@airesvsg
Copy link
Owner

Hi @ethanclevenger91,
I found the error. I'll update the plugin.

Thanks

@airesvsg
Copy link
Owner

airesvsg commented Jul 28, 2016

Hi @ethanclevenger91 & @Specik,

I fixed the erro, but you need to add this code below in your function.php.

Filter reference: {dir-acf-pro}/core/location.php:1186

add_filter( 'acf/location/rule_match/options_page', function( $visibility ) {
    if ( ! is_admin() ) {
        return true;
    }

    return $visibility;
} );

Thanks

@ethanclevenger91
Copy link
Author

@airesvsg The above code causes all fields to show when I'm using ACF fields outside of the admin, like the following scenario: https://www.advancedcustomfields.com/resources/create-a-front-end-form/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants