Check if specific username is logged in

wp_get_current_user then compare the object that’s returned user_login proprety with the specific username you’d like to check against. <?php add_action(‘admin_init’, ‘wpse74389_check_username’); function wpse74389_check_username() { $user = wp_get_current_user(); if($user && isset($user->user_login) && ‘username_to_check’ == $user->user_login) { // do stuff } }

Display edit link if post author is current user

If you just have to modify the author.php page, this piece of code will probably work : <?php if( is_user_logged_in() && is_author(get_current_user_id()) ) { edit_post_link(‘edit’, ”, ”); } ?> The first part of the conditions checks if there is a user logged. The second one will be true if the current page is the author … Read more

Set up collaborative site

I implemented a MU site similar to this a few years ago and there are some caveats you need to consider before going that direction. It’s helpful to think of an MU installation is a convenient way of accessing the administration of multiple, independent WordPress installations. It operates not much differently than if you installed … Read more

Is there a way to set a user profile to Draft?

The database table for users holds the user_status as integer: $users_single_table = “CREATE TABLE $wpdb->users ( ID bigint(20) unsigned NOT NULL auto_increment, user_login varchar(60) NOT NULL default ”, user_pass varchar(255) NOT NULL default ”, user_nicename varchar(50) NOT NULL default ”, user_email varchar(100) NOT NULL default ”, user_url varchar(100) NOT NULL default ”, user_registered datetime NOT … Read more

get_users is expecting unserialized meta_value

In your original code, you’re not passing an operator to meta_compare. Note that get_users() does not define a default operator. Try using ‘=’: $args = array( ‘meta_key’ => ‘custom-usermeta’, ‘meta_value’ => $cat_id, ‘meta_compare’ => ‘=’ ); $users = get_users( $args ); As a diagnostic, you might make sure that the problem isn’t the saving/querying by … Read more

Different back-end colour scheme for the different sites of a multisite

Add to your functions.php file the following code, this will hook into your admin header section and will place the style you chose accordingly to the matching site. add_action(‘admin_enqueue_scripts’, ‘my_admin_background’); function my_admin_background() { wp_enqueue_style( ‘custom-style’, get_template_directory_uri() . ‘/css/custom_script.css’ ); global $blog_id; $color=””; if ($blog_id == 1) { $color=”white”; } elseif ($blog_id == 2) { $color=”red”; … Read more

Keep one user logged for a year?

get_currentuserinfo() is a pluggable function, it is not available during plugins load stage. That aside you shouldn’t be adding filter conditionally, but use data provided by the filter. If you take a look at filter calls: apply_filters( ‘auth_cookie_expiration’, 14 * DAY_IN_SECONDS, $user_id, $remember ) $user_id is provided as second argument. You just have your filter … Read more

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