Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to get the group_id from the "groups_join_group" action in buddypress

  • Avatar of Vicky A M R
    Vicky A M R
    Participant

    @amrvignesh

    I want to get the GROUP_creator_id when an user joins any GROUP.  So if I got the group_id after immediately performing the the groups_join_group action by add_action method.

    needed help.

    Thanks, Vicky

Viewing 4 replies - 1 through 4 (of 4 total)
  • Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    The groups_join_group action gets passed the group_id as its first parameter:

    e.g. do_action( ‘groups_join_group’, $group_id, $user_id );

    So, you have the group_id already.

     

    Interestingly, there doesn’t seem to be a function to get the creator – so, you would then either have to:

    Create a new BP_Group instance using the group_id, and directly access the it’s ->creator_id attribute, or
    Make a direct SQL call on $bp->groups->table_name to return the creator_id where the id = group_id

     

    Avatar of Vicky A M R
    Vicky A M R
    Participant

    @amrvignesh

    Thanks @roger , All know that without having the group_id , no one canot perform the ‘groups_join_group’ , But I need this group_id as follows,

    function get_group()

    {

    return group_id();

    }

    add_action(‘groups_join_group’,’get_group’);

    I need the get_group() function should return the group_id where it is hooked into ‘groups_join_group’ as add_action.

    @Roger you can try more :)

    Does any one can get this :) thanks

    Avatar of Roger Coathup
    Roger Coathup
    Participant

    @rogercoathup

    As I said previously, the group_id is passed as the first parameter to the action.

    You need to add the parameters to your function.

    If you are not familiar with writing action functions in WordPress, you should read here: http://codex.wordpress.org/Function_Reference/add_action

     

    Avatar of Vicky A M R
    Vicky A M R
    Participant

    @amrvignesh

    well, worked , Thanks @rogercoathup

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

You must be logged in to reply to this topic.