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

Pods extended User cannot save first_name, last_name #4041

Closed
lougreenwood opened this issue Mar 9, 2017 · 12 comments
Closed

Pods extended User cannot save first_name, last_name #4041

lougreenwood opened this issue Mar 9, 2017 · 12 comments
Assignees
Labels
Keyword: Has Bounty Donor has reached out to us and funded this specifically Type: Bug
Milestone

Comments

@lougreenwood
Copy link

When extending wp_user with pods, $pod->save() does not save the first_name or last_name values.

$pod->save([
    'first_name' => 'new_fn',
    'last_name' => 'new_ln',
]);

Doesn't result in a saved user first/last name.

@sc0ttkclark
Copy link
Member

@lougreenwood what happens to $pod above this?

@sc0ttkclark sc0ttkclark self-assigned this Mar 20, 2017
@sc0ttkclark sc0ttkclark added this to the Pods 2.6.8.1 milestone Mar 20, 2017
@jimtrue
Copy link
Contributor

jimtrue commented Apr 4, 2017

Related #1890 and #3430

@jimtrue
Copy link
Contributor

jimtrue commented Apr 4, 2017

In addition @sc0ttkclark for your reference, these fields also are not available in the magic tag syntax/template reference, which probably means we're not 'presenting' them.

Correction: They're actually available as they're user_meta, they're just not 'visible'. I had to traverse into them through the relationship field to users.

@lougreenwood
Copy link
Author

lougreenwood commented May 11, 2017

@sc0ttkclark

when do you call that save() and on what page?

save() is called by a hook which is triggered when saving another Pod (let's called it related_pod). I have the same issue when saving related_pod via wp-admin or front-end.

what is done with $pod above your ->save() call?

I have a wrapper which I use as an interface to updating a pod, this is the code which my internal code calls to update the field:

    /**
     * Update an existing record.
     * @param  int      $id       ID of record to be updated.
     * @param  array  $fields Record fields & values to be saved.
     */
    public static function update( int $id, array $fields ){
        // Initalise the pod for this controller's associated model
        $pod = \pods( static::SLUG );

        // Update the entry
        return $pod->save( $fields, null, $id );
    }

@sc0ttkclark
Copy link
Member

My test code works for this. So it looks like there's another problem going on here. Have you extended the Users pod yet? You need to extend that wp object with Pods first before you can start saving fields to it with pods().

@sc0ttkclark sc0ttkclark added the Keyword: Has Bounty Donor has reached out to us and funded this specifically label May 15, 2017
@lougreenwood
Copy link
Author

@sc0ttkclark Yep, Users has been extended.

I have an idea for how to reproduce, we can discuss it in Slack as some details are private.

@rosalynpoort
Copy link

I'm having the same issue, when i display a form for user pod (extended wp user) the first name, last name, description fields don't show.
$mypod = pods( 'user' ); echo $mypod->form();

@sc0ttkclark
Copy link
Member

@rosalynpoort please create a new issue for that, this is a separate issue about saving, yours is an issue about the form fields shown by default for users.

@sc0ttkclark sc0ttkclark added the Status: Could not reproduce Issue cannot be reproduced label May 18, 2017
@sc0ttkclark sc0ttkclark modified the milestones: Pods 2.7, Pods 2.6.9 May 18, 2017
@louisgan
Copy link

louisgan commented Jun 1, 2017

Could be the new updates on W3 Total Cache causing the issue or because of certain cache configuration. I cleared cache and disabled W3TC plugin and this issue went away.

@louisgan
Copy link

louisgan commented Jun 1, 2017

Ah could be related to issue #4005 when using redis

@lougreenwood
Copy link
Author

lougreenwood commented Jul 17, 2017

@sc0ttkclark

My test code works for this. So it looks like there's another problem going on here. Have you extended the Users pod yet? You need to extend that wp object with Pods first before you can start saving fields to it with pods().

Do you still have the test code? Curious to see what field name you use for first name & last name...

Just stumbled into this bug again

@sc0ttkclark sc0ttkclark removed the Status: Could not reproduce Issue cannot be reproduced label Aug 2, 2017
sc0ttkclark added a commit that referenced this issue Sep 6, 2017
@ghost ghost added the Status: In Progress Issue or PR is currently in progress but not yet done label Sep 6, 2017
@sc0ttkclark
Copy link
Member

Took me long enough, finally debugged this deep enough to find the issue!

@ghost ghost removed the Status: In Progress Issue or PR is currently in progress but not yet done label Sep 6, 2017
@sc0ttkclark sc0ttkclark added Keyword: Has Bounty Donor has reached out to us and funded this specifically and removed Keyword: Has Bounty Donor has reached out to us and funded this specifically labels Sep 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Keyword: Has Bounty Donor has reached out to us and funded this specifically Type: Bug
Projects
None yet
Development

No branches or pull requests

5 participants