Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

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

  • laloptk
    Participant

    @laloptk

    Ok, I solved the problem, turns out I was using wrong the $bp->loggedin_user->id because only returns a value when the user is loggedin, and I wanted to add members to groups when they activate their account, so, the return in that case (members activating their account are not logged in) is 0.

    The same applys to the function: get_member_nfl_team(), it tries to get the ID of the logged in user.

    I made some modifications to the code and worked perfectly:

    function add_members_to_nfl_group($user_id){ // I suppose when you add the parameter $user_id in the fuction and then pass it trough the action 'bp_core_activated_user', the action returns the ID of the memeber beeing activated. 
        $nfl_team = bp_get_profile_field_data('field=2&user_id='.$user_id); // I erased the function get_member_nfl_team() and put the variable here with the new $user_id
        $nfl_team_slug = str_replace(" ", "-", strtolower($nfl_team));
        $group_slug = "aficionados-a-los-".$nfl_team_slug;
        $group_id = BP_Groups_Group::group_exists($group_slug);    
        groups_join_group( $group_id, $user_id ); // Instead of groups_accept_invite() as @henrywright suggested
    }
    add_action( 'bp_core_activated_user', 'add_members_to_nfl_group' );

    And thats all.


    laloptk
    Participant

    @laloptk

    I tried that @henrywright, but no luck. I’m activating test accounts from WP backend manually, maybe that has something to do with the code not adding members to groups. I don’t know if there’s a difference for ‘bp_core_activated_user’ if the admin activates the account from backend or if the member activates the account from their e-mail.

    Right now I can’t send e-mails from my localhost and can’t test if activating by e-mail works.


    laloptk
    Participant

    @laloptk

    The file is bp-custom.php, finger error above.

Viewing 3 replies - 1 through 3 (of 3 total)
Skip to toolbar