widness
1/10/2018 - 1:35 PM

Wordpress css_on_role plugin

Wordpress css_on_role plugin

<?php
/*
Plugin Name: Wordpress website css on role
Description: Add css in the front-edn depend the user role
Author: Raphaël Balet
Text Domain: css-on-role
*/

function css_on_role()
{
    $user = wp_get_current_user();
    if( ! empty( $user ) && count( array_intersect( [ "seller", "partner" ], (array) $user->roles ) ) ) 
    { // For role List 
        wp_enqueue_style( 'my-style', get_template_directory_uri().'css/some-style.css' );
    }
    elseif(current_user_can("dropshiper"))
    { // For only one role
        wp_enqueue_style('on_role_css',plugins_url( 'css/some-style.css' , __FILE__ ) );
    }
}
add_action('admin_init','css_on_role');

?>