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

Update class-acf-to-rest-api-acf-api.php #247

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jacktator
Copy link

Applied Fix from #141
Fixed #241 #129

@airesvsg
Copy link
Owner

Hello @jacktator,
Thanks for your time and your PR.
I'll test and merge if all right.
Thanks

@@ -130,8 +132,17 @@ 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 ) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -61,7 +61,9 @@ public function get_id( $object ) {
$this->id = $object->term_id;
}
}

if(is_string($this->id)){
$this->id = preg_replace("/[^0-9,.]/", "", $this->id );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why dot and comma?

@evvvritt
Copy link

Hi @airesvsg and @jacktator, thanks for working on this. Much appreciated if this could be merged so updating Users works fluidly. (@jacktator - perhaps you didn't see @airesvsg's comments?) Thanks

@jacktator
Copy link
Author

@airesvsg Hi. Sorry for the super late reply.

As suggested in original comment, I merely applied the fix suggested by @ghost .

I'm not sure how or why it worked, but it did.

I just bumped into the same issue again in another project, and applied this fix again, and it's still working.

So it would be much appreciated if you could have a look at the original issues and the fix suggested. Thank you.

@qduborper
Copy link

Hi, this fix doesn't work anymore for me using latest version for ACF Pro (5.7). It seems that the acf_get_field_groups function require one more filter parameter user_form in order the request work. So now by replacing

$filter = array('user_id' => str_replace( 'user_', '', $id ) );

with

$filter = array(
    'user_id' => str_replace( 'user_', '', $id ),
    'user_form' => 'edit' 
);

line of 136 of your pull request v3/lib/class-acf-to-rest-api-acf-api.php the update user feature works again. @jacktator can you update your merge request including this change ?

Best regards

@Twansparant
Copy link

This fix works for me, will this get merged someday?

Also this line:

if(is_string($this->id))

should become:

if ( is_string( $this->id) && $this->id !== 'options')

@JoshuaVB
Copy link

JoshuaVB commented Aug 12, 2020

Hi, this fix doesn't work anymore for me using latest version for ACF Pro (5.7). It seems that the acf_get_field_groups function require one more filter parameter user_form in order the request work. So now by replacing

$filter = array('user_id' => str_replace( 'user_', '', $id ) );

with

$filter = array(
    'user_id' => str_replace( 'user_', '', $id ),
    'user_form' => 'edit' 
);

line of 136 of your pull request v3/lib/class-acf-to-rest-api-acf-api.php the update user feature works again. @jacktator can you update your merge request including this change ?

Best regards

Oh my goodness, what a godsend! I applied @ghost's update and it wasn't working (even though all of the old Issues state that it will).

@qduborper update was EXACTLY what was necessary - I cannot thank you enough.

@airesvsg Please please please merge this PR, without it the plugin is completely ineffective at updating User ACF data.

@edouardflowasia
Copy link

Thank you for the fix. This was driving me crazy. Is there any plan to add this fix to next updates ?

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

Successfully merging this pull request may close these issues.

Updating ACF fields for user
7 participants