How to create a dashboard widget for one user

You have to wait for wp_loaded to use get_current_user_id(). Example: add_action( ‘wp_loaded’, ‘wpse_80061_load_dashboard_widget’ ); function wpse_80061_load_dashboard_widget() { if ( 1 === get_current_user_id() ) add_action( ‘wp_dashboard_setup’, ‘wpse_80061_add_dashboard_widget’ ); // your function: // add_action( ‘wp_dashboard_setup’, ‘my_catdb_setup’ ); } function wpse_80061_add_dashboard_widget() { wp_add_dashboard_widget( ‘wpse_80061_widget’, ‘Hey!’, ‘wpse_80061_render_dashboard_widget’ ); } function wpse_80061_render_dashboard_widget() { echo ‘hey!’; } For a dashboard widget … Read more

Get author id from url

On an “author” page get_query_var(‘author’) will give you the ID. get_queried_object() will get you considerably more author information. $author = get_queried_object(); echo $author->ID; // var_dump($author); // to see all of the information available. For retrieving custom author data follow the Codex.

users and usermeta table

install a fresh wordpress setup on your local machine and then have a look at wp_usersmeta table . It contains meta(additional) information for each user.You (admin) can also make data entry specific to any user by this function update_user_meta() in usermeta table. and retrive the same using get_user_meta() funciton. All fields for all users are … Read more

How to list users by custom field?

To fetch users with certain meta field, you can use WP_User_Query class. Check codex manual for it. So you can create a custom shortcode like this: add_shortcode( ‘listusers’, ‘wpse8170_listusers’ ); function wpse8170_listusers( $atts, $content=”” ) { $atts = shortcode_atts( array( ‘company’ => false ), $atts ); if ( empty( $atts[‘company’] ) ) return $content; $query … Read more