OiO.lk Blog PHP Hiding A Specific Class Using CSS For users and show it to admins only in wordpress
PHP

Hiding A Specific Class Using CSS For users and show it to admins only in wordpress


So I’m using this plugin called Mapplic for interactive maps on wordpress
and I’m trying to hide a specific class in it for everyone except admins
so first i added this function to add a class for admin

function add_admin_body_class($classes) {
    if (current_user_can('administrator')) {
        $classes[] = 'is-admin';
    }
    return $classes;
}
add_filter('body_class', 'add_admin_body_class');

then i added the CSS code which is

.mapplic-popup-body {
    display: none !important;
}

body.is-admin .mapplic-popup-body {
    display: flex !important;

now it’s completely not showing the class for everyone including the admins
could anyone help me out with this please ?

so i tried changing the class in CSS from is-admin to wp-admin and it showed the class in the admin dashboard but i wanna see it in the content itself



You need to sign in to view this answers

Exit mobile version