Documentation › Remove Headway metaboxes by user role

Remove Headway metaboxes by user role

By using the current_user_can() function, we can check to see if a user has the role of administrator, and if not, remove the headway metaboxes by using the remove_meta_box()function.

You’ll need to know the ID of the metaboxes you want to target.  And you’ll also need a child theme and place any code in the child theme functions.php.

The code would look something like this:

function remove_theme_metaboxes(){
    if ( ! current_user_can( 'administrator' ) ) { // Only run if the user is not an admin
        remove_meta_box( 'headway-admin-meta-box-template', 'post', 'side' ); // Remove Headway Shared layout Meta Box
add_action( 'do_meta_boxes', 'remove_theme_metaboxes' );

This code goes in the functions.php of a child theme.  DO NOT edit the core Headway functions.php file.

This checks to see if the user is not an administrator and if the user meets that, removes the Shared Layout meta box from the Post screen in WordPress using the do_meta_boxes action.  Note: You can also use capabilities instead of the user role in the current_user_can() function

This article was last updated for Headway version 3.8.3

Copyright © 2016 Vesped Inc. All Rights Reserved. Proudly Powered by Headway and WordPress