Add method for tracking who referred new users
Something I completely missed: use an array as a user_meta value. I had thought arrays weren’t accepted by *_user_meta(). looks like I was wrong and this should make things much easier.
Something I completely missed: use an array as a user_meta value. I had thought arrays weren’t accepted by *_user_meta(). looks like I was wrong and this should make things much easier.
Got it to work $temp_post = get_post($post_id); $user_id = $temp_post->post_author; $user_login = get_the_author_meta(‘user_login’,$user_id); echo $user_login;
You probably haven’t changed the display name, which is probably what is being displayed. “nicename” is used for the author’s posts page url and not for display. UPDATE wp_users SET display_name = replace(display_name, @old_user, @new_user);
update_user_meta will store the value permanently, as you are expecting. How ever in your case, there are multiple scenerio where you can loose those data. Thats the reason you are seeing empty result. First check when are you running the update_user_meta. Is it on every page request. If so then $_POST[‘the new value’] shouldn’t be … Read more
I guess the user-edit screen like tables only. Other check boxes I have are using the the standard table structure. So instead of just using input checkboxes, I’m inserting the check box in the element and the label in the element to follow the structure of the rest of the page. So now my code … Read more
It looks like you’re using a custom meta field but searching default meta attributes. https://codex.wordpress.org/Class_Reference/WP_User_Query WP_User_Query might be a more robust solution. So it would look like something like : $args = array( ‘meta_query’ => array( ‘relation’ => ‘AND’, array( array( ‘key’ => ‘mps_finaldate’, ‘value’ => ”, ‘compare’ => ‘!=’ ), array( ‘key’ => ‘mps_finaldate’, … Read more
I believe your issue is related to getting the correct post object on your single post page. From what I can detect from your question is that $post does not contain the post object which you expect. You must remember, $post is one of those very crappy globals which WordPress uses to store the current … Read more
Sounds to me like “Profiles” should be a custom post type with custom fields. You can then relate the profiles to the users via a custom taxonomy or even more crudely by just storing the Profile post ids as meta data of the User. This would give you the flexibility of offering multiple profiles for … Read more
To store user–specific information WordPress has a user meta, pretty much identical to post meta (also known as custom fields). See get_user_meta() and related functions. Unfortunately WP doesn’t provide any interface or interface helpers for it. You would have to implement that yourself, probably hooking into user profile screen.
Use PHP explode function and convert string into array using a delimiter | then you can use foreach loop. Example:- $str = get_the_author_meta(‘my_pet’, $author_id); $pets_array = explode(‘| ‘, $str); if (is_array($pets_array)) { foreach ($pets_array as $pet) { echo $pet; echo ‘somtext’; echo ‘<br />’; } }