Support » Plugin: WP-Polls » [Plugin: WP-Polls] Only administrators can add polls

  • Hello,

    WP-Polls can only be used by users with Administrator role. Editors cannot add polls. I don’t understand the logic in this.

    I would like to change this, so that our website’s editors will be able to manage polls. Could I please get directions how this can be done?

    Thank you,

    Bira

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hey Bira,

    I was just needed the same functionality and wanted to grant permissions for site editors to manage polls.

    I wanted to add this without touching the plugin’s core files, so future updates could be done with no harm. Luckily, I found an action in the plugin’s activation process to let one do it.

    All you need to do is add these lines to your functions.php file of your template.

    add_action('activate_wp-polls/wp-polls.php', 'tc_add_poll_permissions');
    function tc_add_poll_permissions()	{
    	$add_role = get_role('editor');
    	if(!$add_role->has_cap('manage_polls')) {
    		$add_role->add_cap('manage_polls');
    	}
    }

    After doing that, save the file, and then de-activate the plugin and re-activate it again.
    Now editor can manage polls.

    Have fun,
    Maor.

    Thread Starter Biranit

    (@biranit)

    Maor, you are great – thank you for this.

    I want to challenge this issue a little further:

    There needs to be a separation of roles/capabilities as far as this plugin is concerned:

    Editors should be able to add/edit/remove polls
    Admins should be able to do the above + alter the poll design/uninstall.

    This is something I think the plug-in’s authors should include as an option in one of the next versions…

    But anyway, your solution does the trick for what I need.

    Many thanks!

    Bira

    This plugin create one new capability called “manage_polls”, which is used to grant all permission to whole plugin’s menus.

    Inherent support for splitting permissions should be taken care of by plugin’s author, in order to supply the flexibility to let admin decide who can do what, and this would be by creating more capablitites option.

    Anyway, lacking this inherently in the plugin, we could still add an action to hook the WP building menus and submenus items, and alter them to the needs.

    Add this code to your template’s functions.php file, and it will remove for non admin users the 3 polls submenus that not needed:

    function tc_remove_poll_menus () {
    	global $current_user;
    
    	if (!current_user_can('administrator')) :
    		global $menu;
    		global $submenu; 
    
    		//remove poll sub menus
    		unset($submenu['wp-polls/polls-manager.php'][2]);   //poll options
    		unset($submenu['wp-polls/polls-manager.php'][3]);   //poll template
    		unset($submenu['wp-polls/polls-manager.php'][4]);   //uninsall plugin
    	endif;
    }
    add_action('admin_menu', 'tc_remove_poll_menus');
    Thread Starter Biranit

    (@biranit)

    You rock. Thank you!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WP-Polls] Only administrators can add polls’ is closed to new replies.