Monday, December 22, 2014

How to Allow Contributor to Upload Images in WordPress

As we know that, WordPress does not allow contributors to upload file by default. However, It is easily possible by writing a small amount of code to functions.php file, which is located inside the theme directory.

Check out the below code, you need to paste it in your functions.php file. So, as a result contributor can easily upload an image in WordPress.

Upload Images in WordPress

//Allow contributor role to upload images in WordPress

if ( current_user_can('contributor') && !current_user_can('upload_files') )
    add_action('admin_init', 'allow_contributor_uploads');
function allow_contributor_uploads() {
    $contributor = get_role('contributor');
    $contributor->add_cap('upload_files');
}

0 comments:

Post a Comment