PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Role Management w/o the plugin?

  1. I'm customizing the editor role for my clients and would like them to be able to access gravity forms without relying on a plugin. This is the code for my custom role in the functions.php file...

    if ( !get_role('adminlite') )
    {
    	$caps = get_role('editor')->capabilities;
    	$caps = array_merge( $caps, array(
    		'install_plugins' => true,
    		'activate_plugins' => true,
    		'update_plugins' => true,
    		'delete_plugins' => true,
    		'list_users' => true,
    		'create_users' => true,
    		'edit_users' => true,
    		'delete_users' => true,
    		'unfiltered_upload' => true,
    		'edit_theme_options' => true
    	)); 
    
    	add_role( 'adminlite', 'Administrator Lite', $caps );
    }

    I would like to add gravity forms to it yet the following code doesn't appear to work...

    if ( !get_role('adminlite') )
    {
    	$caps = get_role('editor')->capabilities;
    	$caps = array_merge( $caps, array(
    		'install_plugins' => true,
    		'activate_plugins' => true,
    		'update_plugins' => true,
    		'delete_plugins' => true,
    		'list_users' => true,
    		'create_users' => true,
    		'edit_users' => true,
    		'delete_users' => true,
    		'unfiltered_upload' => true,
    		'edit_theme_options' => true,
    		'gravityforms_create_form' => true,
    		'gravityforms_delete_entries' => true,
    		'gravityforms_delete_forms' => true,
    		'gravityforms_edit_entries' => true,
    		'gravityforms_edit_entry_notes' => true,
    		'gravityforms_edit_forms' => true,
    		'gravityforms_edit_settings' => true,
    		'gravityforms_export_entries' => true,
    		'gravityforms_view_entries' => true,
    		'gravityforms_view_entry_notes' => true
    	)); 
    
    	add_role( 'adminlite', 'Administrator Lite', $caps );
    }

    Can Anyone help me out?

    Posted 14 years ago on Wednesday August 4, 2010 | Permalink
  2. Sending this over to our lead developer so he can take a look...

    Posted 14 years ago on Wednesday August 4, 2010 | Permalink
  3. I copied and pasted your second code snippet and it worked for me. I think the problem is that you had initially created the role without the Gravity Forms permissions. The way the code is written, it won't re-create the role with the new permissions if it has already been created. Try executing the following to remove the role, then try your code again.

    remove_role("adminlite");
    Posted 14 years ago on Thursday August 5, 2010 | Permalink
  4. I should have thought of that! Thanks!

    Posted 14 years ago on Thursday August 5, 2010 | Permalink
  5. Another question - I can't seem to remove the Campaign Monitor option....

    I've added this to the above code

    'gravityforms_campaignmonitor' => false,

    and it doesn't work. Thoughts?

    Posted 14 years ago on Tuesday August 17, 2010 | Permalink
  6. It looks like the Addons have a slightly different way to check for permissions. They will only honor the role management settings if the Members plugin is installed. What you could do is trick them into thinking the plugin is installed by adding the following line of code to your theme's functions.php.

    function members_get_capabilities(){}

    Posted 14 years ago on Tuesday August 17, 2010 | Permalink
  7. What about removing the help option? how would I do that?

    Posted 14 years ago on Tuesday August 17, 2010 | Permalink
  8. I'm not sure if Help is able to be hidden now that you mention it. I'll have to look into it. Have you tried gravityforms_help?

    Posted 14 years ago on Wednesday August 18, 2010 | Permalink