Skip to:
Content
Pages
Categories
Search
Top
Bottom

Set user role on registration so can upload files


  • leanneoleary
    Participant

    @leanneoleary

    Hi,
    I need my users to be able to upload files to the media library and therefore need to somehow automatically set the user role to something other than the default “subscriber” when they register.

    I know in Settings > General you can set the ‘New User Default Role’, however if I change this to a role that allows user uploads this gives access to the main media library. If they could upload to their own media library that would be great but I don’t want everyone seeing everyone elses files in the media library.

    I can’t find any documentation on this within Buddypress on how to do this and so have installed the Members Plugin to see if this would help but I am struggling to find out exactly how this would be implemented.

    Any help would be greatly appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)

  • leanneoleary
    Participant

    @leanneoleary

    Found some code that will ensure only files uploaded that thatuser are displayed inthe Media Library.

    add_action(‘pre_get_posts’,’ml_restrict_media_library’);
    function ml_restrict_media_library( $wp_query_obj ) {
    global $current_user, $pagenow;
    if( !is_a( $current_user, ‘WP_User’) )
    return;
    if( ‘admin-ajax.php’ != $pagenow || $_REQUEST[‘action’] != ‘query-attachments’ )
    return;
    if( !current_user_can(‘manage_media_library’) )
    $wp_query_obj->set(‘author’, $current_user->ID );
    return;
    }


    danbp
    Moderator

    @danbp

    @leanneoleary,

    BuddyPress doesn’t handle the Media Library.
    BuddyPress doesn’t handle registration.

    It’s a bad practice to allow users to upload something to your site until they’re not fully registered. When a user register, WP considers this new account as pending. As long as the user hasn’t activate his account with the activation key, he can only visit the site.

    As you installed BuddyPress, i suggest you use your site à la BuddyPress.
    If you want your members be able to upload files, use BuddyDrive. Each user can upload files from within his profile page and can share them on different levels (public, private, friends only). And much better as the Media Library default behave, each document belong to his user. BuddyDrive attributes a folder to each user who upload a document.

    This is much simplier, well integrated and efficient in a members community as strugling with custom code (and potential errors and security issues).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Set user role on registration so can upload files’ is closed to new replies.
Skip to toolbar