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

Class Field Checkbox and ACF Checkbox bug w/ fix - nested array data #1307

Open
shanemac10 opened this issue Nov 4, 2022 · 0 comments · May be fixed by #1389
Open

Class Field Checkbox and ACF Checkbox bug w/ fix - nested array data #1307

shanemac10 opened this issue Nov 4, 2022 · 0 comments · May be fixed by #1389
Assignees
Labels
needs: dev review This PR needs review by a developer

Comments

@shanemac10
Copy link

FYI - I have the same issue as mentioned here, and did a little digging and it appears the data is double nested in an array when it happens to me. And since you are running the extracting ternary once, it doesn't catch it. I just copy and pasted that ternary (on /wp-user-frontend/includes/fields/class-field-checkbox.php line 183), and it seems to work great now.

Turned this...

    public function render_field_data( $data, $field ) {
        if ( empty( $field['options'] ) || ! is_array( $field['options'] ) ) {
            return;
        }

        $data     = is_array( $data ) ? array_pop( $data ) : $data;
        $data     = explode( '|' , $data );
        $selected = [];

        foreach ( $data as $item ) {

into this...

    public function render_field_data( $data, $field ) {
        if ( empty( $field['options'] ) || ! is_array( $field['options'] ) ) {
            return;
        }

        $data     = is_array( $data ) ? array_pop( $data ) : $data; // <-- added this
        $data     = is_array( $data ) ? array_pop( $data ) : $data;
        $data     = explode( '|' , $data );
        $selected = [];

        foreach ( $data as $item ) {

Ref errors:

Warning: explode() expects parameter 2 to be string, array given in .../public/wp-content/plugins/wp-user-frontend/includes/fields/class-field-checkbox.php on line 185
Warning: Invalid argument supplied for foreach() in .../public/wp-content/plugins/wp-user-frontend/includes/fields/class-field-checkbox.php on line 188
@anik-fahmid anik-fahmid added the needs: dev review This PR needs review by a developer label Feb 16, 2023
@sapayth sapayth linked a pull request Sep 14, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: dev review This PR needs review by a developer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants