ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

member_group variable in php

November 01, 2010 6:39pm

Subscribe [2]
  • #1 / Nov 01, 2010 6:39pm

    rblitadmin

    7 posts

    Hi! I’m trying to grant access to content based on a user’s member group using php. Is there a better way to access it in php than {member_group}? I’ve been able to pull out custom field data in php, but the {member_group} variable gives me problems. If I do this:

    <?php 
        $memberGroup = "{member_group}";
        echo $memberGroup;
    ?>

    I get the member group out in a string form. Its funny though because the string length is 14 characters and $memberGroup[0]=”{" and $memberGroup[1]="m" and $memberGroup[2]="e" and so until you get {member_group}. If you actually display all $memberGroup[0] to $memberGroup[13] in a row you get out the member group in string form again. It seems what EE is doing with it is a postprocessor replace on the string {member_group}. I just want the integer value. Is there an easy way to get an integer?

    Thanks!

  • #2 / Nov 02, 2010 3:21pm

    Ingmar

    29245 posts

    Are you using PHP on Input or Output? That said,

    <?=$this->EE->session->userdata['group_id'];?>

    might be even easier.

  • #3 / Nov 04, 2010 2:07pm

    rblitadmin

    7 posts

    That’s it. Thanks!

  • #4 / Nov 04, 2010 3:17pm

    Ingmar

    29245 posts

    Glad to see that helped. Post again as needed, please.

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases