Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter motat331

    (@motat331)

    I figured it out yall, for anyone else wondering

    $id = get_the_ID();
    $uid = get_current_user_id();
    $gids = maybe_unserialize(get_user_meta($uid,'pm_group',true));
    $user_group_id = $gids[0];
    
    <?php
    if ($user_group_id == 1) {
    	echo "YES";
    } else {
    	echo "NO";
    }
    ?>
    
    
    Plugin Author ProfileGrid Support

    (@profilegrid0)

    Hello?@motat331,

    Code provided by you will check only user’s primary group, it will not work when users is member of multiple groups.

    You may use the below code to check user’s group :

    <?php
    $id = get_the_ID();
    $uid = get_current_user_id();
    $gids = maybe_unserialize(get_user_meta($uid,’pm_group’,true));
    if (in_array(‘1’, $gids))
    {
    ????echo “YES”;
    } else {
    ????echo “NO”;
    }

    ?>

    Let us know if you need any further assistance.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Is it possible to write code like “if group = 1 then”’ is closed to new replies.