We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

logged_in_group_id Resulting In PHP String Instead of Integer

Development and Programming

ROCKET MEDIA's avatar
ROCKET MEDIA
153 posts
14 years ago
ROCKET MEDIA's avatar ROCKET MEDIA

Not sure why, but this won’t work…

$x = {logged_in_group_id};

but this will

$x = “{logged_in_group_id}”;

I figure, fine, ill just input it as a string and then to convert to a integer with this:

$x = intval(“{logged_in_group_id}”);

But this just returns nothing.

Not sure what’s up.

       
Victor Michnowicz's avatar
Victor Michnowicz
95 posts
14 years ago
Victor Michnowicz's avatar Victor Michnowicz

Make sure you do comparisons with “==” not “=”.

Edit: Nevermind, I totally misread what you were trying to ask. You could try just using typecasting with (int). Maybe that will work for you.

       
ROCKET MEDIA's avatar
ROCKET MEDIA
153 posts
14 years ago
ROCKET MEDIA's avatar ROCKET MEDIA

I tried the three variants:

$x = intval(”{logged_in_group_id}”);

$s = ”{logged_in_group_id}”; $x = (int)$s;

$x = ”{logged_in_group_id}”; settype($x, “integer”);

None of these work.

I have found, however, that they DO work if I replace {logged_in_group_id} with a normal integer… For instance – this works.

$x = intval(”1”);

I think this may be an expression engine thing?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
14 years ago
Lisa Wess's avatar Lisa Wess

Mixing PHP and EE tags can be complicated. Why not simply use the full session class?

       
ROCKET MEDIA's avatar
ROCKET MEDIA
153 posts
14 years ago
ROCKET MEDIA's avatar ROCKET MEDIA

I’m not too familiar with the session class. This doesn’t seem to be working.

<?php

$aRestrictedID = array();
$currentGroupID = $this->EE->session->userdata('group_id');

{exp:weblog:entries weblog="page"}
$aRestrictedID[]= 1;
{restrict_page}$aRestrictedID[]= {restrict_to_id};{/restrict_page}
{/exp:weblog:entries}

if ( in_array ( $currentGroupID , $aRestrictedID ) ) {

?>

test

<?php
}
?>
       
Lisa Wess's avatar
Lisa Wess
20,502 posts
14 years ago
Lisa Wess's avatar Lisa Wess

Ah, you’re on EE 1. try this instead.

       
ROCKET MEDIA's avatar
ROCKET MEDIA
153 posts
14 years ago
ROCKET MEDIA's avatar ROCKET MEDIA

Fantastic! Worked great. Thanks 😊

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
14 years ago
Lisa Wess's avatar Lisa Wess

My pleasure! =)

       
Manatax's avatar
Manatax
1 posts
12 years ago
Manatax's avatar Manatax
Mixing PHP and EE tags can be complicated. Why not simply use the full session class?

THANK YOU!!!!!!

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.