I’m having a problem with the popular Advanced Custom fields plugin, trying to update/append rows in repeater fields. I’m trying to migrate all data from one table into user meta and I keep getting the following error.

Catchable fatal error: Object of class WP_Error could not be converted to string in C:\wamp\www\baca\wp-content\plugins\advanced-custom-fields\core\fields_functions.php

I’m not sure what I’m doing wrong as I’m following the resources at http://www.advancedcustomfields.com/resources/functions/update_field/ but not working and I'm not having any luck with the support on their website. Below is the code I’m using. Can someone see what I'm doing wrong?

function add_members() {
    global $wpdb;
    $results = $wpdb->get_results( "SELECT * FROM members" ); 

    foreach($results as $row) {

        $new_user = array(
            'user_login' => $row->CompanyName,
                'user_pass' => wp_generate_password ( 12, false ),
                'user_url' => $row->Website,
                'user_email' => $row->Email,
                'wp_capabilities' => 'Subscriber'

        $pid = wp_insert_user($new_user);

        if($pid) :

        $field_key = "field_52f4fedbcdb79";
        $post_id = $pid;
        $value = get_field($field_key, $post_id);
        $value[] = array(
            "more_contacts_name" => $row->ContactName, 
            "more_contacts_email" => $row->ContactEmail, 
            "acf_fc_layout" => "row_1"
        $value[] = array(
            "more_contacts_name" => $row->ContactName2, 
            "more_contacts_email" => $row->ContactEmail2, 
            "acf_fc_layout" => "row_2"
        update_field( $field_key, $value, $post_id );


add_action( 'edit_user_profile', 'add_members' );
  • one of the ACF functions is getting an error object passed to it instead of data, do some debugging and output everything at each stage to make sure its value is what you expect.
    – Milo
    Feb 11, 2014 at 18:00

2 Answers 2



$post_id = $pid; needs to be $post_id = "user_{$pid}";

Seems pretty obvious now as the id could be for anything.


  • Glad you got it. I had a similar question today regarding on how to use the user id. Found in the docs that I needed to use user_ID.
    – gdaniel
    Jul 29, 2014 at 1:37

I'm surprised you're not getting support from Elliot over at ACF, he is usually very responsive.

Why are you trying to update the ACF field instead of just updating the user meta? What table is the info coming from?

For instance, why can't you just do something like:

$userdata = array(
       'user_login' = get_field['company_name']; //if it's an ACF field
       'user_url' = get_post_meta[$postid, 'website', true]; //If it's just regular meta
wp_insert_user( $userdata );

etc etc

Not the answer you're looking for? Browse other questions tagged or ask your own question.