Posted By

chrisaiv on 09/13/14


Tagged

wordpress


Versions (?)

Wordpress: Remove black bar from mobile phone


 / Published in: PHP
 

If you user logs in and they're on a mobile phone, they might get that annoying black bar on top. This script removes that if they can edit posts or on mobile.

  1. /** ******** ******** ******** ******** ******** ******** ******** ********
  2. * Checks if a particular user has a role.
  3. * Returns true if a match was found.
  4. *
  5. * http://codex.wordpress.org/Roles_and_Capabilities#Subscriber
  6. * http://docs.appthemes.com/tutorials/wordpress-check-user-role-function/
  7. *
  8. * @param string $role Role name.
  9. * @param int $user_id (Optional) The ID of a user. Defaults to the current user.
  10. * @return bool
  11. */
  12. if (!current_user_can('edit_posts') || wp_is_mobile() ) {
  13. show_admin_bar(false);
  14. }

Report this snippet  

You need to login to post a comment.