Home / functions.php / Let contributors upload files
  • How to Let contributors upload files

    let-contributors-upload-files

    Adding this PHP code to the functions.php of your wordpress theme will allow contributors to upload files.

    ( click code to copy )

    wordpress snippet : PHP

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

    ( WordPress codex functions, hooks, in this snippet. )

    init, add_cap, current_user_can, get_role, user_can, add_action,
  • Jamie

    Hey Kevin,

    This is brilliant & works perfectly. Thanks for saving me the need to get a plug in =)