Change site logo according to role

Home Forums Legacy Support Support queries Other issues Change site logo according to role

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #236834
    No One
    Spectator
    Hello, I need a code to change Website's logo according to user's role (Student, Instructor,.... etc.) Thanks for your help
    #236891
    Anshuman Sahu
    Keymaster
    please try adding this given code in your wplms-customizer.php file in wplms customizer plugin :     add_filter('wplms_logo_url',function($logo_url){   if(is_user_logged_in()){     $user_meta=get_userdata($user_id);       $user_roles=$user_meta->roles;       if(empty($user_roles)){       $user_roles = array();     }     if(in_array('student', $user_roles)){         $logo_url = '';//specify the logo url     }elseif(in_array('administrator', $user_roles)){       $logo_url = '';//specify the logo url     }elseif(in_array('instructor', $user_roles)){       $logo_url = '';//specify the logo url     }     }   return $logo_url;  });  
    #236938
    No One
    Spectator
    Thanks for your effort Alex, But unfortunately it's not working :(
    #236939
    No One
    Spectator
    This reply has been marked as private.
    #236940
    No One
    Spectator
    This reply has been marked as private.
    #237005
    logan
    Member
    Hello, try this code. i have tested it is working: replace the url as per your need. add_filter('wplms_logo_url',function($logo_url){ if(is_user_logged_in()){ $user_meta=get_userdata(get_current_user_id()); $user_roles=$user_meta->roles; print_r($user_roles); if(empty($user_roles)){ $user_roles = array(); } if(in_array('student', $user_roles)){ $logo_url = 'http://localhost/wptest/wp-content/uploads/avatars/12/5c4efdc56db35-bpfull.jpg';//specify the logo url }elseif(in_array('administrator', $user_roles)){ $logo_url = 'http://localhost/wptest/wp-content/uploads/avatars/12/5c4efdc56db35-bpfull.jpg';//specify the logo url }elseif(in_array('instructor', $user_roles)){ $logo_url = 'http://localhost/wptest/wp-content/uploads/avatars/12/5c4efdc56db35-bpfull.jpg';//specify the logo url } } return $logo_url; },999,1);
    #237034
    No One
    Spectator
    This reply has been marked as private.
    #237096
    logan
    Member
    Ohh dear its my bad, while i was testing the codes i left a check of print lol :P use this one remove above:

    add_filter('wplms_logo_url',function($logo_url){

    if(is_user_logged_in()){

    $user_meta=get_userdata(get_current_user_id());

    $user_roles=$user_meta->roles;

    if(empty($user_roles)){

    $user_roles = array();

    }

    if(in_array('student', $user_roles)){

    $logo_url = 'http://localhost/wptest/wp-content/uploads/avatars/12/5c4efdc56db35-bpfull.jpg';//specify the logo url

    }elseif(in_array('administrator', $user_roles)){

    $logo_url = 'http://localhost/wptest/wp-content/uploads/avatars/12/5c4efdc56db35-bpfull.jpg';//specify the logo url

    }elseif(in_array('instructor', $user_roles)){

    $logo_url = 'http://localhost/wptest/wp-content/uploads/avatars/12/5c4efdc56db35-bpfull.jpg';//specify the logo url

    }

    }

    return $logo_url;

    },999,1);

    refer: http://prntscr.com/qbvzm6
    #237102
    No One
    Spectator
    Resolved, [//print_r($user_roles);] Thanks Alex, Thanks Logan You are the best : )
    #237116
    logan
    Member

    Dear Friend,

    Glad you’re enjoying the theme & support – thanks for using it! 🙂

    Please write your review. I would really appreciate that! Here: https://themeforest.net/item/wplms-learning-management-system/reviews/6780226

    If I can be of assistance, please do not hesitate to contact me again.

    Closing this topic.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Change site logo according to role’ is closed to new replies.