Hide Bricks and Happy files entries from the user profile page

How can I hide Bricks and Happy files entries from the user profile page
for all users

Two ideas come to mind:

  1. Deregister Hooks:

If you know which hooks are used, add this to your functions.php:

add_action('init', 'remove_custom_hooks');

function remove_custom_hooks() {
    if (!current_user_can('manage_options')) { // Check if not admin
        remove_action('hook_name_for_bricks', 'function_name_for_bricks');
        remove_action('hook_name_for_happy_files', 'function_name_for_happy_files');
    }
}

Replace hook_name_for_bricks, function_name_for_bricks, etc., with the actual hook and function names.

  1. Using Inline CSS in WordPress Admin:

Add this snippet also to your functions.php:

add_action('admin_head', 'hide_elements_in_admin');

function hide_elements_in_admin() {
    if (!current_user_can('manage_options')) { // Check if not admin
        echo '<style>
        .selector-for-bricks, .selector-for-happy-files {
            display: none !important;
        }
        </style>';
    }
}

Change .selector-for-bricks and .selector-for-happy-files to the right CSS selectors.

To use both, just combine the functions in your functions.php file or use a snippet manger like WP Codebox…

There is no “class” or “id” to target… with display none…
the other elements that I have hidden this way also cause a issue, as then the media folder, does not load… so there is another issue as well with happy files, once I hide elements from the profile page

You 100% should not remove the actions for Happyfiles. You can hide the settings pages while it still loads by removing the admin menu…

function ds_remove_menu_pages() {
  if ( !current_user_can('manage_options' ) { // is not administrator
    remove_submenu_page( 'options-general.php', 'happyfiles_settings' );
add_action( 'admin_init', 'ds_remove_menu_pages' ); 
}

Hey @Casper,

not sure why exactly you want to hide those settings but you could add the following snippet to your child theme’s functions.php file (or a code snippet plugin of your choice) to remove the corresponding elements:

add_action( 'admin_footer', function() {
	$current_screen = get_current_screen();
	if ( $current_screen->id === 'user-edit' ) {
		?>

		<script>
		const hfTable = document.querySelector('#bricks_cap_builder_access').closest('table')
		const hfTitle = hfTable.previousElementSibling
		hfTitle.remove()
		hfTable.remove()

		const bricksTable = document.querySelector('#happyfiles_folder_access').closest('table')
		const bricksTitle = bricksTable.previousElementSibling
		bricksTitle.remove()
		bricksTable.remove()
		</script>

		<?php
	}
} );

Let me know if that helps.

Best,

André

1 Like

Thanks, André
your solution works…
I am declutering the profile page to give only basic options to client

How can I hide the Admin Color Scheme, and Application Passwords sections
when I was hiding it with display: none, my happy files broke when I opened the media library