All Good Things Must Come To An End

As you all know, I have been doing WordPress plugins and supporting it for the past 6 years. These 6 years of my life, I have been through my polytechnic education, my national service as well as my university education.

I just graduated from university in December 2009 and have been looking for full-time jobs. I am offered a full-time job and will be starting work on 1st February 2010.

I regret to say that I am NOT ABLE to provide support for my plugins anymore due to my full-time job commitment. I will leave this forum open and let the community help one another.

However, I WILL still update my plugins whenever I can and you still can report bugs to me via email and I will try to fix it.

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - wiredsage

Pages: [1]
1
I searched and found how to allow users other than administrators to post polls, but it was originally all or nothing.  I wanted to allow Editors to only manage and add Polls.  I didn't want them changing the look and feel of the polls (options and templates) and I definitely didn't want them un-installing the wp-polls plugin!!!

So I came up with these modifications.

In polls-add.php you need to modify the first bit of code at the top of the file:
Code: [Select]

### Check Whether User Can Manage Polls
if(!current_user_can('add_poll')) {
   die('Access Denied');
}


Disable the plugin by going to "Plugins | Installed | WP-Polls | Deactivate".  Then edit the recently disabled plugin.

Find the Poll Administration Menu function and modify it to look like the following:
Code: [Select]

### Function: Poll Administration Menu
add_action('admin_menu', 'poll_menu');
function poll_menu() {
if (function_exists('add_menu_page')) {
add_menu_page(__('Polls', 'wp-polls'), __('Polls', 'wp-polls'), 'manage_polls', 'wp-polls/polls-manager.php', '', plugins_url('wp-polls/images/poll.png'));
}
if (function_exists('add_submenu_page')) {
add_submenu_page('wp-polls/polls-manager.php', __('Manage Polls', 'wp-polls'), __('Manage Polls', 'wp-polls'), 'manage_polls', 'wp-polls/polls-manager.php');
add_submenu_page('wp-polls/polls-manager.php', __('Add Poll', 'wp-polls'), __('Add Poll', 'wp-polls'), 'add_poll', 'wp-polls/polls-add.php');
add_submenu_page('wp-polls/polls-manager.php', __('Poll Options', 'wp-polls'), __('Poll Options', 'wp-polls'), 'edit_plugins', 'wp-polls/polls-options.php');
add_submenu_page('wp-polls/polls-manager.php', __('Poll Templates', 'wp-polls'), __('Poll Templates', 'wp-polls'), 'edit_plugins', 'wp-polls/polls-templates.php');
add_submenu_page('wp-polls/polls-manager.php', __('Uninstall WP-Polls', 'wp-polls'), __('Uninstall WP-Polls', 'wp-polls'), 'delete_plugins', 'wp-polls/polls-uninstall.php');
}
}


And at the very end of the file you'll find this comment.  Replace the comment to the end of the file to look like this:
Code: [Select]

// Set 'manage_polls' Capabilities To Administrator
$role = get_role('administrator');
if(!$role->has_cap('manage_polls')) {
$role->add_cap('manage_polls');
}
if(!$role->has_cap('add_poll')) {
$role->add_cap('add_poll');
}
$role = get_role('editor');
if(!$role->has_cap('manage_polls')) {
$role->add_cap('manage_polls');
}
if(!$role->has_cap('add_poll')) {
$role->add_cap('add_poll');
}
$role = get_role('author');
if(!$role->has_cap('add_poll')) {
$role->add_cap('add_poll');
}
cron_polls_place();
}
?>


And now this will allow Authors to Add Polls, but not Manage them.  Editors can Manage and Add Polls, but can't change options or templates.  And Administrators have complete control.

I wasn't sure if Authors could delete other people's polls or not.  I was assuming they could.  However, I didn't test whether they could or not when they had the manage_polls right, so I'm not sure.  It would be interesting to know if anyone has time.   I don't want polls to appear and disappear off my site too rapidly.  So I thought that the editors can modify the POLL PAGE to publish the poll for the general audience.  Although the newly created polls will show up on a POLL ARCHIVE page. 

It would be nice to have the ability to approve polls... if anyone can hack something together for that quickly.

Thanks.

Pages: [1]