• Resolved hulleman

    (@hulleman)


    Hi,

    Thank you for an awesome plugin.

    So I have a b2b site with a company role setup where each “customer” belongs to a company. The company admin can add the employees to the company by a simple add user form.

    What I would like to do is to add the created user to a group with the same name as the company. Essentially like the join_group thing but in this case its an admin user that creates the user.

    The php for the current action is:(Where $this->company is defined to the admin users company)

    add_user_meta($user_id, 'wcb2brp_company', $this->company);
    add_user_meta($user_id, 'wcb2brp_company_user_role', filter_input(INPUT_POST, 'wcb2brp_role'));
    update_user_meta($user_id, 'wcb2brp_company_user_status', 'active');
    wcb2brp_add_update_company_capabilities($user_id);

    So what I would like is for it to grab the company name and make the created user join the group.

    Any help would be great!

Viewing 1 replies (of 1 total)
  • Plugin Author Kento

    (@proaktion)

    Hi there,

    Thanks for your kind comment on the plugin!

    So, if I understand you correctly, you basically want to add the user to the corresponding group following that code – you can do this easily by following the first example on http://docs.itthinx.com/document/groups/api/examples/

    If you want to obtain the required $group_id for the call, you can do so by name:

    if ( $group = Groups_Group::read_by_name( 'Foobar' ) ) {
        Groups_User_Group::create( array( 'user_id' => $user_id, 'group_id' => $group->group_id ) );
    }

    Keep in mind that the group must already exist, but you can also create it on the fly using the API functions.

    Cheers

Viewing 1 replies (of 1 total)

The topic ‘Company and Group’ is closed to new replies.