Get User ID from within a plugin

If you want current user id only then use get_current_user_id. because it reduce execution time. get_current_user_id get only current user id where wp_get_current_user get all user data. Else every things is perfect. $user_id = get_current_user_id(); $loc_statuss = $wpdb->get_row( “SELECT status FROM profile_location INNER JOIN relation_user ON profile_location.loc_id=relation_user.loc_id WHERE relation_user.user_id=”.$user_id ); $loc_status = $loc_statuss->status;

Total number of authors with more than one post

I believe that wp_list_authors will do what you want, sort of. You could run the function with the echo parameter false and count the results. $authors = wp_list_authors( array( ‘echo’=>false, ‘html’=>false ) ); echo var_dump($authors); echo count (explode(‘,’,$authors)); Or, alternately, and perhaps less profligately, steal that function’s SQL. $authors = $wpdb->get_results( “SELECT DISTINCT post_author, COUNT(ID) … Read more

Navigation link to specific user page

While you could possibly add a filter to walker_nav_menu_start_el and have your callback function alter/recreate the menu item according to your needs, I would say the best and easiest solution is to implement you own menu walker, and supply that to wp_nav_menu. This should help get you started: class WPSE_90204_Walker extends Walker_Nav_Menu { function start_el( … Read more

Overview with latest edited posts and pages

You can use the $WPDB query to query the DB, an example would be: $editedposts = $wpdb->get_results( ” SELECT ID, post_title FROM $wpdb->posts WHERE post_modified = between DateAdd(DD,-7,GETDATE() ) and GETDATE() ” ); This lists all posts which have been edited in the last 7 days (not tested), you would do something similar to get … Read more

Get all commenters on a post

I’m a little unclear as to exactly the final data you’re looking for. You said “array form”, but that’s not specific enough. So based on your code snippet, this code will provide you an array of all unique commenter user IDs. The code is essentially the same as yours, but I’ve combined a few parts … Read more

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