• Hi everyone,

    I’m trying toto customize the dashboard of my blog according to my users roles.
    specifically I want to delete some widgets, place some new, delete some menu entries, change the css.

    now, I’m not good at coding and I need your help.

    I read that to adress a user role, in my case an author, I can you this code:

    global $current_user;
         get_currentuserinfo();
    
         if ($current_user->user_level < 3)

    nice.
    I need however to know how to use this with other functions, like the one to remove widgets:

    function remove_dashboard_widgets(){
      global$wp_meta_boxes;
      unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
      unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_recent_comments']);
      unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']);
      unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_incoming_links']);
      unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_right_now']);
    }
    add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

    (and yes, nazi moderator, it’s 9 lines of code, not 11 like the one you deleted for exceeding of 1 the 10 lines rule.)

    if you can also explain the theory of how you built the code I can do it myself for the next customization.

    however any help is very welcome because I’m stuck.

    thank you guys!

    Michel

Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator keesiemeijer

    (@keesiemeijer)

    Please refrain from calling anyone a “nazi” on these forums (and elsewhere for that matter).

    Use current_user_can().
    example:

    if(current_user_can('contributor')){
    // remove dashboard widgets for contributors.
    add_action('wp_dashboard_setup', 'remove_dashboard_widgets');
    }

    You can even use a plugin to create new Roles with the capabilities you want, to hide parts of the wp-admin. It’s also possible to use the code example above for that new role.
    http://wordpress.org/extend/plugins/members/

    Thread Starter M1chel

    (@m1chel)

    first, thank you kindly!
    your help means a lot and I’m gonna try this bit of code right away 🙂

    second, yeah the nazi thing was provocative, but this is a place to seek help and give each other a hand. erasing someone’s code from a post just because it exceeds of 1 line the general rule is a misuse of moderating power.
    I didn’t have a notification so I didn’t see the action taken and my topic was as a result useless.
    I understand the rule, it’s meant to avoid long pages of code cluttering the topics, but 1 line over the limit doesnt change anything.
    that being said, I’m sorry if I offended someone, it was a lightheart comment not intended to cause problems. 🙂
    I suggest however to be careful giving moderation power to people who can handle wisely the task and actually help the community.

    thanks again for helping me.

    Moderator keesiemeijer

    (@keesiemeijer)

    I suggest however to be careful giving moderation power to people who can handle wisely the task and actually help the community.

    All moderators here have a different idea of what to much code is. But all are here because they have helped this community for many years.

    I hope the code works.

    The limits for posting code are quite clearly defined in http://codex.wordpress.org/Forum_Welcome Unless you’re a member of Spinal Tap, 11 is not 10.

    Thread Starter M1chel

    (@m1chel)

    I have great respect for moderators helping the community and I admire the fact they spend time to help users like me.

    So, I’ll avoid getting in a debate about what 10 line means or is. I’ll just thank you again for the help.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘custom dashboard per user role’ is closed to new replies.