lewismcarey / User-Field-ACF-Add-on

User Field Add on for Advanced Custom Fields
40 stars 19 forks source link

Add custom fields to user #13

Open pbolger opened 12 years ago

pbolger commented 12 years ago

Hi

I'm trying to add custom fields to my users - phone, cell and the like. This works fine in the back end, the form elements appear and seem to save, but I can't seem to get the values back in a template. If I use

 <?php 

 foreach($values as $value)
 {
      echo '<pre >';
           print_r($value);
      echo '</pre >';
 }

?>

I can only see the native user fields.

Array
 (
      [ID] => 3
      [user_firstname] => 
      [user_lastname] => 
      [nickname] =>
      [user_nicename] =>
      [display_name] => 
      [user_email] => 
      [user_url] => 
      [user_registered] => 2012-08-21 21:53:18
      [user_description] => This is my description field.
  )

(values redacted)

shaunbent commented 11 years ago

This add-on only returns the all the native user fields. You would have to take the users ID and use a get_user_meta query to grab any custom meta details. I will look to see if there is a way to grab all the other user_meta and add it to the returned array.

pbolger commented 11 years ago

Here's some discussion about this at the ACF forums.

http://support.advancedcustomfields.com/discussion/1207/add-custom-field-to-user/p1

It'd be really nice to be able to do this. My goal a DRY cms: 'people' should only exist in one place, and the WP user list is the obvious one.