Contact Form 7 plugin menu access

If you wish to manage Contact Form 7 plugin menu access you can be misleaded by capabilities which CF7 uses when defines its menu:

add_menu_page( __( 'Contact Form 7', 'contact-form-7' ),
		__( 'Contact', 'contact-form-7' ),
		'wpcf7_read_contact_forms', 'wpcf7',
		'wpcf7_admin_management_page', 'dashicons-email',
		$_wp_last_object_menu );

$edit = add_submenu_page( 'wpcf7',
		__( 'Edit Contact Form', 'contact-form-7' ),
		__( 'Contact Forms', 'contact-form-7' ),
		'wpcf7_read_contact_forms', 'wpcf7',
		'wpcf7_admin_management_page' );

$addnew = add_submenu_page( 'wpcf7',
		__( 'Add New Contact Form', 'contact-form-7' ),
		__( 'Add New', 'contact-form-7' ),
		'wpcf7_edit_contact_forms', 'wpcf7-new',
		'wpcf7_admin_add_new_page' );

$integration = add_submenu_page( 'wpcf7',
			__( 'Integration with Other Services', 'contact-form-7' ),
			__( 'Integration', 'contact-form-7' ),
			'wpcf7_manage_integration', 'wpcf7-integration',
			'wpcf7_admin_integration_page' );

As you can see from the piece of code above, CF7 plugin declares own custom user capabilities and protects its admin menu this way:

Contact – wpcf7_read_contact_forms
Contact Forms – wpcf7_read_contact_forms
Add New – wpcf7_edit_contact_forms
Integration – wpcf7_manage_integration

But you will not find these capabilities at the “Custom Capabilities” section of User Role Editor. Why it’s happened? Be cause of CF7 does not really use this capabilities. CF7 uses WordPress core user capabilities mapping technique and really uses this list of WordPress built-in user capabilities:

wpcf7_edit_contact_form => publish_pages
wpcf7_edit_contact_forms => publish_pages
wpcf7_read_contact_forms => edit_posts
wpcf7_delete_contact_form => publish_pages
wpcf7_manage_integration’ => manage_options

So you can use these built-in capabilities to manage access to the “Contact” menu of CF7 plugin.

If you wish to use another capabilities (your own), it’s possible to change this default mapping via custom filter ‘wpcf7_map_meta_cap’. This filter takes a single parameter – array with a default mapping of user capabilities, like shown above. For example:

add_filter('wpcf7_map_meta_cap', 'change_cf7_capabilities',10,1);

function change_cf7_capabilities($meta_caps) {
    $meta_caps = array(
        'wpcf7_edit_contact_form' => 'cf7_edit_forms',
	'wpcf7_edit_contact_forms' => 'cf7_edit_forms',
	'wpcf7_read_contact_forms' => 'cf7_read_forms',
	'wpcf7_delete_contact_form' => 'cf7_delete_forms',
	'wpcf7_manage_integration' => 'cf7_manage_integration' );

    return $meta_caps;


You can insert this code into your active theme functions.php file or setup it as a Must Use plugin.

Be aware in order to provide access to CF7 plugin “Contact” menu with these new custom capabilities you should create them manually using “User Role Editor -> Add Capability” button, then grant them to the selected role.