Notifications
Clear all

Restricting who can upload videos

4 Posts
2 Users
0 Reactions
474 Views
Posts: 3
Topic starter
(@ronnyadsetts)
Active Member
Joined: 8 months ago

Hi,

We want to restrict who can post videos using wpDiscuz Media Uploader by their membership status on the website we're working on.

Something like a hook to limit file-types allowed when posting comments.

Does the plugin have a hook like that available?

Thanks.

Ronny

3 Replies
Astghik
Posts: 5997
Admin
(@astgh)
Illustrious Member
Joined: 7 years ago

Hi Ronny,

There is the following hook you can use:

$allowedRoles = apply_filters("wpdiscuz_mu_allowed_roles", $this->getDefaultRoles());

Here the $this->getDefaultRoles() is an array of the user roles. E.g. ['administrator', 'editor', ....].

Reply
Posts: 3
Topic starter
(@ronnyadsetts)
Active Member
Joined: 8 months ago

Hi Astghik,

I think wpdiscuz_mu_allowed_roles will not do what I need - it seems to be apply to all uploads whereas I want to restrict only a certain type of uploads.

Your response did help me discover what seems to be filetype filtering on the upload input:

$allowedExts = apply_filters("wpdiscuz_mu_allowed_extensions", "accept='image/*'");

The media uploader plugin currently does this:

add_filter("wpdiscuz_mu_allowed_extensions", function() {
            return "";
        });

This should allow me do what I want I think.

So thanks I think. :-). I'll update the post once I've had a go at it.

Ronny

 

Reply
Posts: 3
Topic starter
(@ronnyadsetts)
Active Member
Joined: 8 months ago

To follow up on this now I have it working, I used these two filter hooks:

add_filter( 'wpdiscuz_mu_allowed_extensions', 'ainet_allowed_upload_extensions', 15, 1 );

add_filter( 'wpdiscuz_mu_mime_types', 'ainet_allowed_upload_mimetypes', 15, 1 );

Both used priority 15 so they came after the media uploader hooks.

The first hook allows us to set the HTML accept attribute which gives the browser an indication of which file types will be accepted. The second allows the AJAX hook on the server to reject mime types we don't want.

Reply
Share:
Scroll to top