How to add another user to this remove_menu function?

Why not just add another if? function remove_menus(){ global $menu; global $current_user; get_currentuserinfo(); //check first user if($current_user->user_login == ‘user1’){ $restricted = array( __(‘Links’), __(‘Comments’), __(‘Appearance’), __(‘Plugins’), __(‘Profile’), __(‘Tools’), __(‘Settings’) ); end ($menu); while (prev($menu)){ $value = explode(‘ ‘,$menu[key($menu)][0]); if(in_array($value[0] != NULL?$value[0]:”” , $restricted)){unset($menu[key($menu)]);} } } //check second user if($current_user->user_login == ‘user2’){ $restricted = array( __(‘Links’), … Read more

What is the difference between “create_users” and “add_users” capabilities?

I explored WordPress to find difference between it and in schema.php file i found the following function only where in WordPress add_users capability is used. /** * Create and modify WordPress roles for WordPress 3.0. * * @since 3.0.0 */ function populate_roles_300() { $role =& get_role( ‘administrator’ ); if ( !empty( $role ) ) { … Read more

Multisite Independent User Base

This is not exactly worpdress multisite suggestion, but a hack to run and manage multiple wordpress websites. I don’t know if it works for you : STEP 1. Move your wordpress installation to its own directory say common (Instructions can be found at http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory) STEP 2. Change the path of wp-content folder and move it … Read more

Give editors access to particular plugin – turn “admin.php” into “edit.php”

As I mentioned, it’s not the best practice to edit the plugin’s source codes because this will be overwritten if you were to get the latest update from the author. Nonetheless, to allow the Business Opening Hours plugin to show for your Editors open /business-opening-hours/bizo-hours.php and tweak the following lines. At the time of this … Read more

pre_get_posts Remove posts based on meta value with ‘post__not_in’

Try this version: // Get all posts with the access level of ‘Member’ function members_get_member_posts() { $post_ids = wp_cache_get( ‘wpse61487_members_posts’ ); if ( false === $post_ids ) { $post_ids = array(); $args=array( ‘post_type’ => ‘any’, ‘meta_key’ => ‘_members_access_role’, ‘meta_value’ => ‘member’, ‘post_status’ => array(‘publish’,’private’) ); $protected_posts = get_posts($args); if($protected_posts) { $post_ids = wp_list_pluck( $protected_posts, ‘ID’ … Read more

Issue with front-end ajax, getting a 302 redirect when accessing wp-admin/admin-ajax.php

Below function works for me by adding !defined(‘DOING_AJAX’) in condition. function custom_blockusers_init() { if ( is_admin() && !defined(‘DOING_AJAX’) && ( current_user_can(‘usercrp’) || current_user_can(‘userpcp’) || current_user_can(‘subscriber’) || current_user_can(‘contributor’) || current_user_can(‘editor’))) { session_destroy(); wp_logout(); wp_redirect( home_url() ); exit; } } add_action( ‘init’, ‘custom_blockusers_init’ );

How to make user inactive by default while registering?

/* Plugin Name: Role-less New Users Description: Removes all roles from new registrations. Author: 5ubliminal */ // Hook into the registration process add_action(‘user_register’, function($user_id){ $user = new WP_User($user_id); // Remove all user roles after registration foreach($user->roles as $role){ $user->remove_role($role); } }, 11); Create a new .php file. Paste the code above in it. Put it … Read more

Is there a way to set the user Role based on email domain

With this code, you will check during the registration the users email and attach the roles you want to: <?php add_action( ‘user_register’, ‘wp234_set_role_by_email’ ); function wp234_set_role_by_email( $user_id ){ $user = get_user_by( ‘id’, $user_id ); $domain = substr( strrchr( $user->data->user_email, “@” ), 1 ); //Get Domain $contributor_domains = array( ‘gmail.com’ ); if( in_array( $domain, $contributor_domains ) … Read more

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