Support » Plugins and Hacks » WP-Polls » Allow Editor to manage Poll

  • Resolved Xcellence IT

    (@xcellenceit)


    Hi, this is a one of the great polls plugin, its so simple to use.. and most of the times it just works out of the box… Thank you for this great plugin!

    While I was working on a project, I have one requirement. Currently polls are only available to administrator in admin panel. I want to give editors rights to manage Polls.

    Can you please advise how to do that? And more whether it is possible to do without modifying the Plugin using theme function file?

    http://wordpress.org/extend/plugins/wp-polls/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Any update here?

    First Add below code to your theme’s functions.php.

    // add poll for editors
    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');
    	}
    }

    Second: If you want to restrict poll menu to “Manage Poll and Add Poll”
    (hide menu like uninstall and Poll options from editors)add this code

    // remove poll admin options for editors
    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');

    Xcellence IT

    (@xcellenceit)


    Hi, This doesn’t work.

    Just adding that, I’m using Roots theme.

    Any idea?

    kanuharis

    (@kanuharis)


    I don’t know why its not working. Its works fine on my custom theme. Did you pasted below code to functions.php?

    // add poll for editors
    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');
    	}
    }
    // remove poll admin options for editors
    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');

    hmm.. forgot to tell you one thing. You should deactivate and activate the plugin after adding the above code to functions.php
    Please update if it worked..

    Xcellence IT

    (@xcellenceit)


    Hey, thanks for your advise. It works. Earlier I didn’t re-activated the plugin, may be that’s why it was not working. But it does work correctly after deactivating the plugin, and activitating it again.

    Thanks

    kanuharis

    (@kanuharis)


    glad to know that worked

    Xcellence IT

    (@xcellenceit)


    Thank you for your great support. 🙂

    Jake Love

    (@rockymountainhigh1943)


    Yup totally worked. Added to functions, deactivated plugin, reactivated, then BOOM!

    Really appreciate the assistance!

    It works for me too.
    Thank you very much @kanuharis. 🙂
    Wish you all the very best.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Allow Editor to manage Poll’ is closed to new replies.