How can I get the last posts by user role?

I would try the following (not tested) <?php $friends = get_users( array( ‘role’ => ‘friends’ ) ); $friend_ids = array(); foreach( $friends as $friend ) $friend_ids[] = $friend->ID; $news = new WP_Query( array( ‘author’ => implode( ‘,’, $friend_ids ), ‘post_type’ => ‘news’, ‘paged’ => get_query_var(‘paged’) ) ); ?> Note: ‘friends’ is the role ID, not … Read more

Hooking into register_admin_color_schemes

No, you can’t hook into that function since there is no do_action or apply_filters in it, the function itself hooks to admin_init. So if your goal is to add new color schemes you have to hook your code the same way, so using your example, the required code would be something like this: // Define … Read more

How to display multiple custom columns in the wp-admin users.php?

hummm… do you mean something like this : function mysite_column_company( $defaults ) { $defaults[‘mysite-usercolumn-company’] = __(‘Company’, ‘user-column’); $defaults[‘mysite-usercolumn-otherfield1’] = __(‘Other field 1’, ‘user-column’); $defaults[‘mysite-usercolumn-otherfield2’] = __(‘Other field 2’, ‘user-column’); return $defaults; } function mysite_custom_column_company($value, $column_name, $id) { if( $column_name == ‘mysite-usercolumn-company’ ) { return get_the_author_meta( ‘company’, $id ); } elseif( $column_name == ‘mysite-usercolumn-otherfield1’ ) { … Read more

$current_user var returns NULL

You need to globalize $current_user, and then populate it via get_currentuserinfo(). See the Codex entry for get_currentuserinfo(). In the Codex-example usage: <?php global $current_user; get_currentuserinfo(); ?> So, try adapting your code accordingly; e.g.: class My_plugin_class{ var $user; function __construct() { //Set the current user global $current_user; get_currentuserinfo(); $this->user = $current_user; print_r($this->user); } }

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