diff --git a/v3/lib/class-acf-to-rest-api-acf-api.php b/v3/lib/class-acf-to-rest-api-acf-api.php index dfea978..3071dfa 100755 --- a/v3/lib/class-acf-to-rest-api-acf-api.php +++ b/v3/lib/class-acf-to-rest-api-acf-api.php @@ -65,7 +65,7 @@ public function get_id( $object ) { if ( 'option' == $this->type ) { $this->id = sanitize_title( $this->id ); } else { - $this->id = absint( $this->id ); + $this->id = preg_replace("/[^0-9]/", "", $this->id); } return $this->format_id(); @@ -74,7 +74,7 @@ public function get_id( $object ) { public function get_fields( $request ) { $data = array(); $field = null; - + if ( $request instanceof WP_REST_Request ) { $field = $request->get_param( 'field' ); } @@ -130,7 +130,16 @@ public function get_field_objects( $id ) { $fields_tmp = array(); if ( function_exists( 'acf_get_field_groups' ) && function_exists( 'acf_get_fields' ) && function_exists( 'acf_extract_var' ) ) { - $field_groups = acf_get_field_groups( array( 'post_id' => $id ) ); + + if ( strpos( $id, 'user_' ) !== false ) { + $filter = array( 'user_id' => str_replace( 'user_', '', $id ) ); + } elseif ( strpos( $id, 'taxonomy_' ) !== false ) { + $filter = array( 'taxonomy' => str_replace( 'taxonomy_', '', $id ) ); + } else { + $filter = array( 'post_id' => $id ); + } + + $field_groups = acf_get_field_groups( $filter ); if ( is_array( $field_groups ) && ! empty( $field_groups ) ) { foreach ( $field_groups as $field_group ) {