Add these all in your function.php file under in your theme folder.
/*******User permission Section Start here *********/ /* Fire our meta box setup function on the post editor screen. */ add_action( 'load-post.php', 'smashing_post_meta_boxes_setup' ); add_action( 'load-post-new.php', 'smashing_post_meta_boxes_setup' ); /* Meta box setup function. */ function smashing_post_meta_boxes_setup() { /* Add meta boxes on the 'add_meta_boxes' hook. */ add_action( 'add_meta_boxes', 'smashing_add_post_meta_boxes' ); /* Save post meta on the 'save_post' hook. */ add_action( 'save_post', 'smashing_flautist_access_save_meta', 10, 2 ); } /* Create one or more meta boxes to be displayed on the post editor screen. */ function smashing_add_post_meta_boxes() { add_meta_box( 'smashing-flautist-access', // Unique ID esc_html__( 'Select Attendees', 'smashing_flautist' ), // Title 'smashing_flautist_access_meta_box', // Callback function 'advisory-boards', // Admin page (or post type) 'normal', // Context 'default' // Priority ); } /* Display the post meta box. */ function smashing_flautist_access_meta_box( $object, $box ) { ?> ID ); $user_role = new WP_User($user->ID); $userRoles =$user_role->roles[0];if( $userRoles=='editor') { $displayRole="Fully Privileged"; }else { $displayRole="Restricted"; }if(in_array($user->user_login, get_post_meta( $object->ID, 'smashing_flautist_access', true ))) $ifchecked = 'checked="checked" '; echo " ";echo "$user->user_login"; echo " user_login\" " . $ifchecked ."/>"; echo " $displayRole"; echo ""; unset($ifchecked);} ?>Username | Visiblity | User Role |
---|
/* Get the post's acceptable viewer. */ $flautist_access = get_post_meta($post->ID, 'smashing_flautist_access', true ); /* Get the post's current viewer, if he or she is logged in. */ if(is_user_logged_in()) {$current_flautist = $current_user->user_login;} /* See if the acceptable viewer and the current viewer are the same */ //print_r($flautist_access);
//echo $flautist_access." == ".$current_flautist; //echo '<br>'.$current_flautist;
if((in_array($current_flautist, $flautist_access)) || current_user_can('administrator')) { //put private content section here
}
- /***************Admin private for admin only*************/
/* * Hide the admin bar in the front end */ add_filter('show_admin_bar', '__return_false');
/* * Redirects Editor Authors and Subscribers to the site front page using: get_home_url() */ add_action('admin_init','wpse_53675_block_users'); function wpse_53675_block_users() { if( current_user_can('author') || current_user_can('subscriber') || current_user_can('editor')) { wp_redirect( get_home_url(), 301 ); exit; } }
/***************Remove Auto save Section Start here**********/function disableAutoSave(){ wp_deregister_script('autosave'); } add_action( 'wp_print_scripts', 'disableAutoSave' );
/*****************Auto save Section End here***********/ /**************Disable Priview button Section Start here***********/// Admin Custom Post Page Specific CSS function posttype_admin_css() { global $post_type; if($post_type == 'meeting' || $post_type == 'page' || $post_type == 'advisory-boards') { echo ''; } } add_action('admin_head', 'posttype_admin_css');
/*********Disable Priview button Section End here**********/