BuddyDev

Restrict allowed file types for BuddyPress Avatar and Cover Images

BuddyPress allows your users to use "jpeg", "gif", "png" file types for avatars and cover images.  If you need to restrict or change the allowed file types, there exists a filter  "bp_attachments_get_allowed_types" that allows us to do it.

Let us see some examples on how to restrict the allowed file types for avatars as well as the cover image on a BuddyPress site.

Restricting allowed file types for BuddyPress User & Group Avatars

You can put the following code in your bp-custom.php or in your theme/child theme's functions.php to restrict the file type.

Make sure to change the $exts array with your own allowed types.

Result:-

Restricting allowed file types for BuddyPress User & Group Cover Image

Again, we use the same filter but check for the cover_image based o n type parameter.

Result:-

It works same as avatar.  You can put it in your bp-custom.php or theme's functions.php

Have fun.

Comments are closed.