Tuesday, September 28, 2010

WordPress: Using the user_has_cap Filter

I finally worked out a WordPress plugin of mine that utilizes the user_has_cap filter. Thankfully John B. on the wp-hackers list had an example of how he used it in his plugin, since there was practically no documentation on this filter!

A simple example of mine would be:

function a_user_cap($allcaps, $cap, $args) {
$allcaps['upload_files'] = true;
return $allcaps;
}

add_filter('user_has_cap', 'a_user_cap', 10, 3);


Now, you can see it's basically giving the "upload_files" capability to all users. Thank you WP Hackers!

Cheers!

No comments: