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

Filter for options exposes all fields to front-end users #60

Closed
ethanclevenger91 opened this issue Aug 18, 2016 · 2 comments
Closed

Filter for options exposes all fields to front-end users #60

ethanclevenger91 opened this issue Aug 18, 2016 · 2 comments
Labels

Comments

@ethanclevenger91
Copy link

ethanclevenger91 commented Aug 18, 2016

After all this time using GitHub, I'm still not sure if notifications go out on closed issues, so thought I would create a new one.

In order to get Options pages working correctly, you implemented a filter on ACF's rule matching, but this filter isn't particularly nuanced (specifically the is_admin check), so if I'm allowing users to edit fields from the front end, it ends up displaying all options fields as well as those I intend to display.

@airesvsg
Copy link
Owner

Hi @ethanclevenger91,
This filter is used because ACF limits the visibility of the options values. This error isn't in my plugin, please open a new thread here: https://support.advancedcustomfields.com/forums/forum/add-ons/options-page/

Thanks

@ethanclevenger91
Copy link
Author

Hey @airesvsg ,

I'm digging through and trying to find a way around this. Can you describe what exactly is happening in this function? The call to update_field will accept the name of the field rather than the key and should be available in all versions of ACF (I think), so I'm trying to understand why a simpler pass-through isn't an option, like:

public function update_item( $request ) {
        if ( $request instanceof WP_REST_Request ) {
        $key  = apply_filters( 'acf/rest_api/key', 'fields', $request, $this->type );

        if ( is_string( $key ) && ! empty( $key ) ) {
            $data  = $request->get_param( $key );

            $field = $request->get_param( 'field' );

            $this->format_id( $request );

                        update_field($key, $data, $this->id);

                return new WP_REST_Response( $this->get_fields( $request ), 200 );
                }
    }
}

I'm sure there's something pretty nuanced you're trying to do instead so I'm trying to understand what that is before I run around making pull requests.

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

2 participants