How to insert new element to existing array in usermeta?

Let’s analyze your code and what it does. Assuming that the current fruits stored in the database are ‘pineapple’ and ‘orange’, get_user_meta(2, ‘fruits’, false) will return something like this: array( array( ‘pineapple’, ‘orange’ ) ) This is because you passed false as the third argument, $single. The function returns an array if $single is false … Read more

Gravity Custom Merge Tags [closed]

You need to add the new merge tags with the gform_custom_merge_tags filter, and then replace them with the gform_replace_merge_tags filter, like this: Edit: you need to use the gform_field_content filter to replace the field’s default value, see below. add_filter(‘gform_custom_merge_tags’, ‘wpse_121476_custom_merge_tags’, 10, 4); add_filter(‘gform_replace_merge_tags’, ‘wpse_121476_replace_merge_tags’, 10, 7); add_filter(‘gform_field_content’, ‘wpse_121476_field_content’, 10, 5); /** * add custom merge … Read more

Getting $user_id for the_author_meta outside the loop in multisite

Not sure how this would differ with multi-site, but this is how you’d do this outside the loop normally: <?php # get post data $temp_post = get_post($post_id); # grab the author meta $user_id = $temp_post->post_author; # grab the field you’re looking for $first_name = get_the_author_meta(‘first_name’,$user_id); # display field echo $first_name; ?>

Multiple User-Meta Values in One User-Meta Key

If you check out the documentation for the update_user_meta() function, you’ll note that the $meta_value parameter already accepts objects and arrays, so you can simply save a user’s positions in an array without any additional effort: update_user_meta( 22, ‘position_names’, array( ‘Khaleesi of the Great Grass Sea’, ‘Breaker of Chains’, ‘Mother of Dragons’ ) ); The … Read more

get current user not working

Have you tried to go with the “Safe usage” alternative given in the commented section? I honestly don’t have any experience with wp_get_current_user(), since I never use it, but anyhow, this ought to work: global $current_user; echo ‘Username: ‘ . $current_user->user_login . ‘<br />’; echo ‘User email: ‘ . $current_user->user_email . ‘<br />’; echo ‘User … Read more

How to get the user description with get_users?

The Native get_users() function returns an array of user objects and each on holds [ID] => 1 [user_login] => admin [user_pass] => $P$Bxudi6gJMk2GRt2ed3xvZ06c1BPZXi/ [user_nicename] => admin [user_email] => [email protected] [user_url] => http://localhost/ [user_registered] => 2010-06-29 07:08:55 [user_activation_key] => [user_status] => 0 [display_name] => Richard Branson as you can see user_description is not a part of … Read more

Get user’s ID on logout

I think I figured this one out. I had misread this answer and hooked the function I wrote to wp_clear_auth_cookie (actually a function itself!) instead of clear_auth_cookie (the real hook), so that wasn’t working. But now using the real hook, I think it might be. Correct me if I’m wrong. Below is the function with … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)