Skip to:
Content
Pages
Categories
Search
Top
Bottom

[Resolved] Group join date

  • @marcella1981

    Participant

    I’d like to show when a user joined a group on the groups > members page. I looked in the bp_group_members table and found a field date_modified, but not sure if this is the one I’m looking for.

    Anyone have any advice on how to find the correct database column to query and then output that within a bp_group_has_members() loop.

    Thankssss

Viewing 4 replies - 1 through 4 (of 4 total)
  • @djpaul

    Keymaster

    This is a good question. I took a look at the code. As far as I can tell, you can safely use this column as a “when did the user join the group” value for most cases. It’s set when:

    * A user joins a group
    * A user accepts or declines an invite to join a group
    * When a user creates a group

    Promoting/demoting a user to moderator/administrator/regular member doesn’t change the value.

    Note that this column isn’t indexed. This is only a consideration if for whatever reason you need to write your own SQL queries, which you shouldn’t need to. If you can’t find a core function that gets the data you need, it would be great if you can let me know here or on https://buddypress.trac.wordpress.org/ and we can add one.

    @marcella1981

    Participant

    I don’t know of any core functions off the top of my head… It’s been a while since I’ve used WPDB but will take a look.

    @megainfo

    Participant

    date_modified field contain the data of the latest group join ( ie: if the member join and leave then he join again a group, this field contain this date).

    check the code of function groups_join_group( $group_id, $user_id = 0 )

    Here a small code that can help you to fetch the join date

    
    global $bp;
    
    $user_id = 2;  //user id
    $group_id = 1; // your group id
    
    $join_date_sql = $wpdb->prepare( "SELECT date_modified FROM {$bp->groups->table_name_members} WHERE is_confirmed = 1 AND is_banned = 0 AND user_id = %d AND group_id= %d", $user_id, $group_id );
    $join_date = $wpdb->get_var( $join_date_sql );
    
    

    @marcella1981

    Participant

    I just found this function

    <?php bp_group_member_joined_since(); ?

    It does exactly what I need.

    Thanks for the help.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Resolved] Group join date’ is closed to new replies.
Skip to toolbar