Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to show pending memberships to user


  • nickofnight
    Participant

    @nickofnight

    What I want is for a user to know (from going to their profile page or w/e) what groups they have applied to and are waiting to hear back from.

    I saw there was a groups_check_for_membership_request and a groups_check_user_has_invite but I don’t want to loop through all groups to do a check for the user.

    Is there a way to display pending memberships on the users page?

    Thanks!

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

  • shanebp
    Moderator

    @shanebp

    afaik, there is no BP function for that.
    You could gather all the group ids like so:

    function get_all_group_membership_requests( $user_id ) {
    	global $wpdb;
    
    	$bp = buddypress();
    
    	return $wpdb->get_col( $wpdb->prepare( "SELECT group_id FROM {$bp->groups->table_name_members} WHERE user_id = %d AND is_confirmed = 0 AND inviter_id = 0", $user_id ) );
    }

    Use:
    $pending_group_ids = get_all_group_membership_requests( bp_loggedin_user_id() );


    nickofnight
    Participant

    @nickofnight

    @shanebp Thanks that is perfect! I now have a list of requested groups with a link to them.

    One last question (honest) – is there a way a member can cancel their membership request. I am sure I remember there being a way to do this but I can’t find anything about it searching on google.


    shanebp
    Moderator

    @shanebp

    You already have the group ids.
    Write a function to show a ‘delete’ button per id.
    Write a function to delete that row.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How to show pending memberships to user’ is closed to new replies.
Skip to toolbar