Hooks Generator

Overview

Use this tool to create custom Hooks with add_filter() and add_action() functions.

Usage

  • Fill in the user-friendly form.
  • Click the “Update Code” button.
  • Copy the code to your project.
  • Or save it as a snippet and share with the community.

Examples

If you are still learning how to use this tool, check out the following examples:

Actions of filters.
Which filter/action you want to hook into?Hook Information
The name of the function to be called.
The order in which the function associated with this particular hook is executed.
The # of arguments the function accepts.
The names of the arguments listed in the callback function.
Custom code in the function.
  Save Snippet
function hide_admin_menus( $context ) {
	
	// Hide from users with low privilege 
	if ( ! current_user_can( 'manage_options' ) ) {
	
		// Core Menus
		remove_menu_page( 'index.php' );               //Dashboard
		remove_menu_page( 'edit.php' );                //Posts
		remove_menu_page( 'upload.php' );              //Media
		remove_menu_page( 'edit.php?post_type=page' ); //Pages
		remove_menu_page( 'edit-comments.php' );       //Comments
		remove_menu_page( 'themes.php' );              //Appearance
		remove_menu_page( 'plugins.php' );             //Plugins
		remove_menu_page( 'users.php' );               //Users
		remove_menu_page( 'tools.php' );               //Tools
		remove_menu_page( 'options-general.php' );     //Settings
	
		// Plugins
		remove_menu_page( 'jetpack' );                 //Jetpack
	
	}
	
}
add_action( 'admin_menu', 'hide_admin_menus', 10, 1 );