0

Some of the employees at my organization need to be able to upload files to a folder and share a link with others. It’s primarily documents like pictures, pdf’s and Word documents. And instead of creating a completely new File Management System, I was thinking about just using the built-in Wordpress Media Library function for this task.

But my problem is, that I want to create a User Role with permissions to only do that and nothing else. If possible, also hide all other option panels, custom post types, etc.

I’ve been reading a bit about User Roles and Capabilities, and founded a Plugin but I think it is a bit much to install a large plugin when it is the only User Role I need to create. And more, I would like to learn some more about it and I think this is a good way to do it.

Any help would appreciate.

Sincere - Mestika

0

Install Justin Tadlock's Members Plugin. It has per-configured roles that allow in-depth control over users. If the standard roles don't allow the amount of access control you want, you can create a custom role and assign your specific access level.

  • Upvoting, even though the question says "I don't want to install a Plugin". I think the best answer here is for the OP to study the Plugin, to learn what it's doing, which will in turn answer his question. – Chip Bennett Jan 25 '12 at 14:05
3

something like this : https://codex.wordpress.org/Function_Reference/add_role then

if ( current_user_can('new_role') && !current_user_can('upload_files') )
add_action('admin_init', 'allow_new_role_uploads');


function allow_new_role_uploads() {
    $new_role = get_role('new_role');
    $new_role->add_cap('upload_files');
}
0

If you have created a custom role to add new capabilities add this code to them function.php

function add_theme_caps(){
    global $pagenow;

    // gets the author role
    $role = get_role( 'teacher' );
    $role2 = get_role( 'school' );

    if ( 'themes.php' == $pagenow && isset( $_GET['activated'] ) ){ // Test if theme is activated
        // Theme is activated

        // This only works, because it accesses the class instance.
        // would allow the author to edit others' posts for current theme only
        $role->add_cap( 'upload_files' );
        $role2->add_cap( 'upload_files' );
    }
    else {
        // Theme is deactivated
        // Remove the capability when theme is deactivated
        $role->remove_cap( 'upload_files' );
        $role2->remove_cap( 'upload_files' );
    }
}
add_action( 'load-themes.php', 'add_theme_caps' );

Dactivate and active theme to make changes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.