Allow User to Upload Images – PHP Code Snippet

In WordPress theme there’s no option for contributes to upload images. In fact, WordPress doesn’t allow users to do so until you give them privilege. You’ll have to make them Editor or Author so images can be uploaded by them but code snippet facilitate Allow User to Upload Images. They don’t even need any additional privileges.

Permit User to Upload Images – PHP Code Snippet

Paste it in the functions.php file of your theme.

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');
}

Your email address will not be published. Required fields are marked *

More Stories
Web design guide: 69 website design tips for breathtaking websites