Remove custom Branding for a specific user on Child Sites

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.

tried using the specific username snippet and executed on child site but didn’t work. any suggestions?

That is really strange, I tried on my setup, but it worked.

Can you please provide me more details?

nevermind… seems to work now. not sure why it didn’t on the first few attempts.

Thanks for letting us know. I am glad to see it’s working now.