Advertisement
Guest User

Untitled

a guest
Jun 29th, 2017
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. function pc_admin_index_notice(){
  2.  
  3. global $pagenow;
  4.  
  5. if ( !($pagenow == 'index.php') ) {
  6. return;
  7. }
  8.  
  9. $user = wp_get_current_user();
  10.  
  11. if ( !in_array( 'administrator', (array) $user->roles ) ) {
  12. return;
  13. }
  14.  
  15. echo '<div class="notice notice-info is-dismissible">
  16. <p>Click on <a href="edit.php">Posts</a> to start writing.</p>
  17. <h1>HELLO WORLD!! This page is index.php and you are Administrator</h1>
  18. </div>';
  19. }
  20.  
  21. add_action('admin_notices', 'pc_admin_index_notice', 11);
  22.  
  23.  
  24. // ======================================
  25.  
  26. function pc_delete_all_admin_notices() {
  27. $admin_user_ID_with_notices = '1';
  28.  
  29. $user = wp_get_current_user();
  30. $user_data = $user->data;
  31.  
  32. if ( in_array( 'administrator', (array) $user->roles )
  33. && $user_data->ID == $admin_user_ID_with_notices ) {
  34. return;
  35. }
  36.  
  37. global $wp_filter;
  38.  
  39. $wp_filter['admin_notices'] = null;
  40.  
  41. }
  42.  
  43. add_action('init', 'pc_delete_all_admin_notices', 999);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement