Hey there! any question in your mind? Ask It Now!.

Popular Categories





Error is coming in WordPress while using get_user_meta.

+1 vote
183 views
asked in Programming by payel (1,640 points)
retagged by Bhartesh

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.

commented by monika (2,040 points)
edited by Bhartesh
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
answered by ramesh (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.

Related Questions

+5 votes
1 answer 74 views
+8 votes
3 answers 123 views
+6 votes
2 answers 1,557 views
+6 votes
1 answer 238 views
+2 votes
1 answer 139 views
+3 votes
3 answers 2,451 views
+2 votes
1 answer 90 views
+8 votes
2 answers 277 views
+1 vote
1 answer 64 views
asked in Programming by Brinz

Not a Member yet?

Ask to Folks Login

My Account
649 Folks are online
62 members and 587 guest online
Your feedback is highly appreciated