Using BuddyPress Member Types

Using BuddyPress Member Types

If you haven’t downloaded BuddyPress 2.2 as yet then you are wasting time. BP 2.2 features the new BuddyPress Member Type which is pretty awesome if you use it right. Check out how to get member types on your site.

Member Types can be used in many ways depending on your project. Let’s assume that you would like to have members types for a firm intranet social network. You can define member types based on the staff structure. So, let’s assume our firm is made of the following positions; Accountants, Designers and Sales Agents. Now, let’s create these member types in our BP site.

Firstly, the function for registering member types is bp_register_member_type

PHP

1

bp_register_member_type($member_type,$args=array())

Step 1. Create a file called bp-custom.php in the plugins directory

Step 2. Add a bp_init filter

PHP

1

add_action('bp_init','mpl_register_member_types');

Step 3. Create the mpl_register_member_types function

PHP

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

functionmpl_register_member_types(){

$types=array();

$types['accountants']=array(

'name'=>'Accountants',

'singular_name'=>'Accountant'

);

$types['designers']=array(

'name'=>'Designers',

'singular_name'=>'Designer'

);

$types['sales_agents']=array(

'name'=>'Sales Agents',

'singular_name'=>'Sales Agent'

);

if(!empty($types)){

foreach($typesas$key=>$type){

bp_register_member_type($key,array(

'labels'=>array(

'name'=>$type['name'],

'singular_name'=>$type['singular_name'],

),

));

}

}

}

Now, you save your file and find the member type under the XProfile section in the admin.