Skip to:
Content
Pages
Categories
Search
Top
Bottom

How can I get all userId for a given Member type


  • amitgupta3
    Participant

    @amitgupta3

    Hi,
    I am new to Buddypress, found member_type as a good feature. I am facing hard time to use it in my code.
    — I want to send Bulk email to all members of a Member_Type say ‘Principal’ or ‘Doctor’.
    I have member_type slug hard coded.

    How can I get all userId for a given Member_type ? Can someone please help. I tried many many discussion thread and plugin code. but unluck so far.

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

  • amitgupta3
    Participant

    @amitgupta3

    Any Reply/suggestion please ?


    shanebp
    Moderator

    @shanebp

    You need to provide the $type_id for the Member type:

    $get_user_ids = $wpdb->get_col( "SELECT u.ID FROM {$wpdb->users} u INNER JOIN {$wpdb->prefix}term_relationships r ON u.ID = r.object_id WHERE u.user_status = 0 AND r.term_taxonomy_id = " . $type_id );


    amitgupta3
    Participant

    @amitgupta3

    oh thanks. Looks like it works.
    it returns an array. I will ready how to display an array.
    But thanks for help!


    Peter Hardy-vanDoorn
    Participant

    @petervandoorn

    If getting your hands dirty with SQL scares you (like it does me) BP has its own functions:

    $member_type = "doctor"; // slug of member type
    if ( bp_has_members( array ( 'type' => 'alphabetical', 'per_page' => 1000, 'member_type' => $member_type ) ) ) {
    	while ( bp_members() ) : bp_the_member();
    		// code
    	endwhile;
    }

    amitgupta3
    Participant

    @amitgupta3

    Oh Great. Thanks. I used the SQL one.
    Though I got answer this time, I wonder if there should be a documentation for these inbuilt function. Atleast one or two lines then that will be great help. wld save time.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar