+1 vote
831 views
in Programming by (1.8k points)
retagged by

Hi all, I am trying to add additional metadat and for this i am using get_user_meta like this see the code : 

if ( !get_user_meta( $wcm_users[$i], $key, '' ) ) {

 

add_user_meta( $wcm_users[$i]->ID, $key, '' );

 

}

 

here $get_user_meta is an array, which is coming with several meta and here I am trying to check if that meta is already added so want to skip that product.

 

Some how facing this error:

Notice: Object of class WP_User could not be converted to int in /.../wp-includes/functions.php on line 2999

When I remove get_user_meta error doesn't come.

Please help me out on the same.

0
by (2.8k points)
edited by
In WordPress there is a function for update meta data may be that function can help you more if you know WordPress very well use update_user_meta() function
it may help you out as per your problem.

1 Answer

+3 votes
by (630 points)

If you are using get_user_meta() it takes an integer ID, So you should try like this :

 

  foreach( $metadata as $key => $value ) {

 

if ( !get_user_meta( $wcm_users[$i]->ID, $key, '' ) ) {

 

add_user_meta( $wcm_users[$i]->ID, $key, '' );

 

}

}

It may help you.

Not a Member yet?

Ask to Folks Login

My Account

Your feedback is highly appreciated