How to access author data from header action

The global $authordata variable is only available by default when $wp_query->is_author() && isset($wp_query->post) condition is satisfied. It means that you can’t access $authordata inside a single post page. You may try to get author data via $wp_query: add_action(‘wp_head’, function() { global $wp_query; $userdata = get_userdata($wp_query->post->post_author); $avatar_url = get_avatar_ur($userdata->user_email); … }, 10, 0);

Display author name, outside the loop, if they haven’t published a custom post

author’s name or logged in user’s name? can use global $current_user; or wp_get_current_user(); if the user is logged in. if( is_user_logged_in() ) { $current_user = wp_get_current_user(); echo $current_user->user_firstname; } for specific user role you can check $current_user->roles array. Reference: https://codex.wordpress.org/Function_Reference/wp_get_current_user https://codex.wordpress.org/Function_Reference/get_currentuserinfo

a:0:{} is replaced into database as s:6:”a:0:{}”;

API calls are API calls, not database writes. What and how information is stored in the DB is usually best left as an unknown since, unless explicitly defined in the API, it might change. Specifically in this case, wordpress will serialize the value being passed, and since you are passing a string it is serialized … Read more

Problem when try to add ++1 for user meta

The problem here is twofold: the ++ operator is applied on an array. the user id and the meta key need to be swapped in get_user_meta() So use get_user_meta( $user_id, “_user_count”, true ); to get user meta. Note that the third input parameter is false by default and an array is returned. Setting it to … Read more

Check role of Username then echo something if administrator [closed]

@terminator answer might work but there’s no need to create an array and use array_intersect I think since you’re only looking for one role. This might be more comprehensible: $current_user = wp_get_current_user(); $roles = (array) $current_user->roles; if (in_array(‘administrator’, $roles) { /* echo whatever */ } Don’t forget to check that ‘administrator’ is acutally the role … Read more

User description only displayed for logged user

I have tested your code on my side, and it works perfectly. The relevant info displays, whether I’m logged in or not. This is definitely not a problem with your code, but more an external problem. You will need to look for any type of code that might restrict this code from showing if a … Read more

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