The CF7 plugin was written at the initial stages of WordPress, prior to the framework maturing its dashboard integration core code and as such, the plugin author created a number of admin pages that extend admin classes in order to integrate the form editor pages. The WordPress core code evolved to the point where a standard mechanism exists today for plugin integration in the dashboard so as to leverage a lot of the functionality that is already built into the admin interface, while the CF7 plugin code has maintained its legacy code to the point that many existing core functionality does not apply to the CF7 plugin. For example adding custom columns to the form table list.
The CF7 forms are stored as a custom post type wpcf7_contact_form
, however, the table list and editor pages are both custom admin pages (as opposed to the edit.php
and post.php respectively). Getting to WP core standard functionality to work on the CF7 plugin will always be a challenge. It is this very reason which led me to develop a plugin extension to bring back the CF7 plugin into the WP core standard. I wrote the Smart Grid-Layout design Extension in order to be able to create responsive grid-layout forms by creating a new form editor that integrates a UI designer. As a result, the table list and form editor pages are now WP core pages, which leverage the full functionality of the framework.
Using this extension, fine-tuning user role access can be achieved using the WordPress capabilities functionality by either defining a new role or adding additional capabilities to an existing role. The CF7 capabilities that allow you to control access are,
'edit_posts' => 'wpcf7_edit_contact_forms'; //controls access to form table
'edit_others_posts' => 'wpcf7_edit_others_contact_forms'; //controls access to forms created by other users.
'edit_published_posts' => 'wpcf7_edit_published_contact_forms'; //ability to edit published forms.
'delete_posts' => 'wpcf7_delete_contact_forms'; //delete forms.
'delete_published_posts' => 'wpcf7_delete_published_contact_forms'; //delete published forms.
'delete_others_posts' => 'wpcf7_delete_others_contact_forms'; //delete forms created by other users.
'publish_posts' => 'wpcf7_publish_contact_forms'; //publish forms, else status are set as pending.
so for example, creating a new role for a form editor,
add_action('init', 'create_cf7editor_role');
function create_cf7editor_role(){
add_role('cf7_editor', 'Form Editor',
array('wpcf7_edit_contact_forms'=>1,
'wpcf7_edit_others_contact_forms'=>1,
'wpcf7_edit_published_contact_forms'=>1,
'wpcf7_read_contact_forms'=>1,
'wpcf7_publish_contact_forms'=>1,
'wpcf7_delete_contact_forms'=>1,
'wpcf7_delete_published_contact_forms'=>1,
'wpcf7_delete_others_contact_forms'=>1)
);
}
publish_pages
cap is required forwpcf7_edit_contact_forms
to work. – Coarsegrained