Answers for "hide menu for subscriber"

PHP
0

hide menu for subscriber

add_action( 'admin_init', 'my_remove_menu_pages' );
function my_remove_menu_pages() {


  global $user_ID;

  if ( current_user_can( 'subscriber' ) ) { //your user id

   remove_menu_page('index.php'); // dashboard
   remove_menu_page('edit.php?post_type=h5p'); // Pages
	  
    echo "<style>
			   .profile-php #ld_course_info,.profile-php .user_status,.profile-php #application-passwords-section,
			   .profile-php .user-sessions-wrap,.profile-php tr,.profile-php h1,.profile-php h2,.profile-php h3,
			   .toplevel_page_h5p{
				display: none ;
				}
				.profile-php #password{
				display:block;
				}
		</style>";
  }
}
Posted by: Guest on October-27-2021

Browse Popular Code Answers by Language