MainWP Child 4.0.3, released on October 1st, 2019, introduced one handy filter mainwp_child_branding_init_options
that can be used to hide custom branding for a specific user on child sites.
Let’s see the usage example:
add_filter( 'mainwp_child_branding_init_options', 'mycustom_mainwp_child_branding_init_options' );
function mycustom_mainwp_child_branding_init_options( $option ) {
$current_user_id = get_current_user_id();
if ( $current_user_id == '1' && is_array( $option ) && isset( $option[ 'cancelled_branding' ] ) ) {
$option[ 'cancelled_branding' ] = true;
}
return $option;
}
In this example, all custom MainWP Branding Extension options will be applied for all users no the child site except for the user with ID 1.
Also, the filter can be used to hide custom branding for a user with a specific username.
add_filter( 'mainwp_child_branding_init_options', 'mycustom_mainwp_child_branding_init_options' );
function mycustom_mainwp_child_branding_init_options( $option ) {
$current_user = wp_get_current_user();
if ( $current_user && $current_user->user_login == 'bogdan' && is_array( $option ) && isset( $option[ 'cancelled_branding' ] ) ) {
$option[ 'cancelled_branding' ] = true;
}
return $option;
}
In this example, the user with the username “bogdan” won’t be affected by the custom branding.
If you use the MainWP Code Snippets Extension, you will be able to apply this snippet to all your sites at once.