How to detect first visit of a user?

No, there’s nothing in the core like that. You can set a cookie and do it simply enough (warning: untested code follows). <?php function is_first_time() { if (isset($_COOKIE[‘_wp_first_time’]) || is_user_logged_in()) { return false; } $domain = COOKIE_DOMAIN ? COOKIE_DOMAIN : $_SERVER[‘HTTP_HOST’]; // expires in 30 days. setcookie(‘_wp_first_time’, ‘1’, time() + (WEEK_IN_SECONDS * 4), “https://wordpress.stackexchange.com/”, $domain); … Read more

How to get the Role Name of the current user? (WordPress)

I’m not sure if bbPress follows WordPress conventions, but WP has a global class called $WP-roles that holds the role information. So, starting from what you have, there is the role of the current user: $current_role = $user->roles[1]; Next, retrieve a list of all roles: $all_roles = $wp_roles->roles; Then, loop through $all_roles and find the … Read more

get_userdata by username

get_userdata() function is an alias of get_user_by(‘ID’) function. Use this code: $username=”your user name”; $user = get_user_by(‘login’, $username); It will return WP_User object on success, or false on failure. See Codex. REST API: http://example.com/wp-json/wp/v2/users/<id>

How to show custom post type count in the users admin page

There are 2 pretty undocumented hooks ‘manage_users_custom_column’ and ‘manage_users_columns’ that you can use for the scope. They works in same manner of ‘manage_posts_custom_column’ and ‘manage_posts_columns’ that are better documented, see Codex. So you can do something like this: /* * Add Event Column */ function users_events_column( $cols ) { $cols[‘user_events’] = ‘Events’; return $cols; } … Read more

Hide comments awaiting moderation from user who submitted the comments

Check in your theme’s comments.php for the wp_list_comments() function. In the Twenty Eleven theme, for example, uses a custom callback function which is in the functions.php file and outputs the template for comments. Within this comments template, you can then use wp_get_comment_status() and only display a comment if it was approved. Example from the Codex: … Read more

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