Support » Plugin: Groups » Check if user is part of grou fails when user is removed

  • Resolved tuastad


    I have a small project and what to have diferent feature availeble accourding to usergroups.
    So, in templet i have:

    $is_a_member = false;
    equire_once( ABSPATH . 'wp-includes/pluggable.php' );
    if ( $group = Groups_Group::read_by_name( $environment ) ) {
    echo $cu}rrent_user->user_login . "is a menber of" . 'TestGroup';

    When i load page after fresh user i get nothing from it
    Then i add it to the Group and it says it’s a member, but if i remove the user it still says its a member.

    Amy idea?

Viewing 1 replies (of 1 total)
  • Hi tuastad,

    On your snippet there are errors. I would recommend you to enable debugging so that you can see these described.
    For example on line 2 you are missing an ‘r’, The correct form is ‘require_once’.
    Furthermore, the correct argument is the group name like this

    Groups_Group::read_by_name( 'the group name should be here' )
    the $environment variable is not defined.
    Also after echo you have a ‘}’ which shouldn’t be there and $current_user is not defined.

    The plugin API could help you with your project, which can be found here.
    FYI, to enable debugging, edit your wp-config.php file and do the following:
    Replace this line: 

    define( ‘WP_DEBUG’, false );
    with these lines:

    define( ‘WP_DEBUG’, true );

    define( ‘WP_DEBUG_LOG’, true );
define( ‘WP_DEBUG_DISPLAY’, false );

    Kind regards,

    • This reply was modified 1 year, 5 months ago by gtsiokos.
Viewing 1 replies (of 1 total)
  • The topic ‘Check if user is part of grou fails when user is removed’ is closed to new replies.