• Hello,
    I have created a new user role named “advertiser” and added some capabilities. Here is list of capabilities for advertiser I use:

    function prefix_add_user_role() {
    	add_role(
    		'advertiser',
    		'Advertiser',
    		array(
    			'switch_themes' => 0,
    			'edit_themes' => 0,
    			'activate_plugins' => 0,
    			'edit_plugins' => 0,
    			'edit_users' => 0,
    			'edit_files' => 0,
    			'manage_options' => 0,
    			'moderate_comments' => 0,
    			'manage_categories' => 0,
    			'manage_links' => 0,
    			'upload_files' => 0,
    			'import' => 0,
    			'unfiltered_html' => 0,
    			'edit_posts' => 1,//
    			'edit_others_posts' => 0,
    			'edit_published_posts' => 1,//
    			'publish_posts' => 1,//
    			'edit_pages' => 0,
    			'read' => 1,
    			'edit_others_pages' => 0,
    			'edit_published_pages' => 0,
    			'publish_pages' => 0,
    			'delete_pages' => 0,
    			'delete_others_pages' => 0,
    			'delete_published_pages' => 0,
    			'delete_posts' => 1,
    			'delete_others_posts' => 0,
    			'delete_published_posts' => 1,
    			'delete_private_posts' => 0,
    			'edit_private_posts' => 0,
    			'read_private_posts' => 0,
    			'delete_private_pages' => 0,
    			'edit_private_pages' => 0,
    			'read_private_pages' => 0,
    			'delete_users' => 0,
    			'create_users' => 0,
    			'unfiltered_upload' => 0,
    			'edit_dashboard' => 0,
    			'update_plugins' => 0,
    			'delete_plugins' => 0,
    			'install_plugins' => 0,
    			'update_themes' => 0,
    			'install_themes' => 0,
    			'update_core' => 0,
    			'list_users' => 0,
    			'remove_users' => 0,
    			'promote_users' => 0,
    			'edit_theme_options' => 0,
    			'delete_themes' => 0,
    			'export' => 0,
    			'edit_comment' => 0,
    		)
    	);
    }
    add_action( 'init', 'prefix_add_user_role' );

    Advertiser has access to contact form page in admin /wp-admin/admin.php?page=wpcf7 and I need for this role to restrict this page and subpages completely. I have followed this tutorial:

    https://contactform7.com/restricting-access-to-the-administration-panel/

    In wp-config file I have added two constants. But when I log in as advertiser, I still can access this page, view created forms and edit them. Not good! Can someone help to resolve my problem? Thank you.

Viewing 1 replies (of 1 total)
  • Thread Starter Juraj Hamara

    (@jurajj)

    I have placed this two constants

    define( 'WPCF7_ADMIN_READ_CAPABILITY', 'manage_options' );
    define( 'WPCF7_ADMIN_READ_WRITE_CAPABILITY', 'manage_options' );

    in wp-config.php after WP debug constant. It’s working now.

Viewing 1 replies (of 1 total)
  • The topic ‘Restrict contact form page in admin’ is closed to new replies.