Kimark Futalan
Kimark Futalan

Reputation: 11

Load CSS per custom role

I want to hide activity posting in buddypress for all users except admin. I want only admin to post update. Is that possible?

heres the css

.activity form#whats-new-form {
display: none;
}

Upvotes: 0

Views: 69

Answers (1)

Aliqua
Aliqua

Reputation: 748

You can use current_user_can()

add_action('wp_head', 'hide_activity');
function hide_activity() {
    if( ! current_user_can('administrator') ){
        echo '<style>
            .activity form#whats-new-form {
                display: none;
            }
        </style>';
    }
}

Goes in your functions.php file or plugin file.

Reference: https://developer.wordpress.org/reference/functions/current_user_can/

Upvotes: 1

Related Questions