This topic has 11 replies, 2 voices, and was last updated 10 years by sharmstr.

  • Author
  • #37948
     Weird Mike
    Participant

    I know this may sound totally non-theme related, but I was wondering if anyone knew of a way to make a users role display a custom template depending on what it is. I would like to have a different CSS style sheet for my Admins, Moderators and users.

    Also, with this option to have their posts show in the activity feed with different color backgrounds to show importance to other users.

    #37979
     sharmstr
    Moderator

    Definitely doable. I haven’t tried to do this, but the first thing that pops into my head is set up everything in Theme Options to what you want to display for users. Then in your childs functions.php file, add a function that will check to see if the logged in user is a moderator or an admin and load a custom css file if so. Something along the lines of (note, this is untested code)

    COPY CODE
    
    if ( current_user_can( 'moderate' ) ) {
    wp_enqueue_style( 'moderator-styel', get_stylesheet_uri() );
    } else if ( current_user_can( 'edit_posts' ) ) {
    wp_enqueue_style( 'admin-style', get_stylesheet_uri() );
    }
    
    

    Then to handle the styling by user type in the activity feed, you’ll have to copy the kleo/buddypress/activity/entry.php file to your child theme and edit it to get the activity user id. Once you have that you can see if the user is an admin or moderator and add different css classes to the divs you want to change.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #37989
     Weird Mike
    Participant

    Okay, so far the code hasn’t popped up any errors when added to my child theme’s functions.php file, but where is the enqueue getting the style sheet from if the get_stylesheet_uri defaults to pulling from wp-includes/theme.php ?

    And to be exact the roles I want to call custom style sheets for are Administrator & Vendor. The style sheet I added in the child theme’s main directory is vendor.css with some CSS edits but nothings being affected.

    #37990
     Weird Mike
    Participant
    This reply has been set as private.
    #37993
     sharmstr
    Moderator

    get_stylesheet_uri looks in your child theme. Read the codex: http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #38577
     sharmstr
    Moderator

    Were you able to get this working?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #38598
     Weird Mike
    Participant

    I was not. I tried many different ways, but still nothing.

    #38605
     sharmstr
    Moderator

    Respond privately with temp admin access and I’ll take a look if you’d like.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #38614
     Weird Mike
    Participant
    This reply has been set as private.
    #38622
     sharmstr
    Moderator

    Its because it can’t find your css file for 2 reasons.

    1 – You used get_template_directory_uri instead of get_stylesheet_directory_uri like I mentioned. The get_stylesheet_directory_uri gets the dir path of your child theme.

    2 – You also need to include a / as in ‘/admin.css’.

    I’ve made the changes for you and its loading now.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

    #38628
     Weird Mike
    Participant
    This reply has been set as private.
    #38631
     sharmstr
    Moderator

    No problem.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    This support site is not about custom work. If you need custom development please contact cornel@seventhqueen.com

Viewing 12 posts - 1 through 12 (of 12 total)

The forum ‘KLEO’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?