Community Forum

Forum Replies Created

  • Mr A B
    Participant
    # il y a 1 année et 2 mois

    That seems clear. Thank you so much for your help.

    Mr A B
    Participant
    # il y a 1 année et 2 mois

    Thank you for your help. I now have the following code that works well inside my customer-account pages and displayes all the groups a customer is in. Where can I add this code to work accross the entire Customer Area and to add a bodyclass?

    $current_user = $this->get_current_user();
    
    // Get the managed-groups and user-group add-on to access required functions
    $mg_addon = cuar_addon('managed-groups');
    $gp_addon = cuar_addon('user-group');
    
    // The current user ID
    $user_ID = $current_user->ID;
    
    // Get an array of group IDs belonging to that user
    $managedGroups = $mg_addon->get_groups_of_user($user_ID);
    $userGroups = $gp_addon->get_groups_of_user($user_ID);       
    
    // get the group name from each ID
    foreach ( $managedGroups as $managedGroup ) {
    $groupClasses .= str_replace(' ', '', strtolower($managedGroup->post_title)) . ' ';
    }
    
    foreach ( $userGroups as $userGroup ) {
    $groupClasses .= str_replace(' ', '', strtolower($userGroup->post_title)) . ' ';
    }
    
    echo $groupClasses;

     

     

2 sujets de 1 à 2 (sur un total de 2)