I am trying to get a php snippet working within a template with PHP enabled(output).

$uid does contain the {member_id} as expected but the php has not returned the correct result.

Update I think this is parse order issue.

What is wrong here?

  $uid = "{member_id}";
  • What EE version? I just tested it on 2.9.3 and it worked exactly as expected.
    – jrothafer
    Commented Apr 13, 2015 at 15:28
  • 2.7.0 @jchrono-battle
    – Derple
    Commented Apr 13, 2015 at 15:33
  • it is working. But the php is not returning the correct result i will look again as it must be parse order issue.
    – Derple
    Commented Apr 13, 2015 at 15:36
  • I know what's going on. Run var_dump ($uid) and see that you're getting a string of much greater length. I've run into this before, if I can remember how I overcame it I will post an answer.
    – jrothafer
    Commented Apr 13, 2015 at 15:39
  • 1
    Well, if you're playing with house money, I'd try Low Variables as a fix. gotolow.com/addons/low-variables
    – jrothafer
    Commented Apr 13, 2015 at 15:58

1 Answer 1


This most likely is parse order, however as your trying to get a global into a php variable you can forget about tag parsing completely. Try this :

$uid = ee()->session->userdata('member_id');

Member ID is in the Session class (if logged in), test the group for if_logged_in or not.

FYI, for other global vars, you can do things like this :

//Global Variables (Site Label)
$var = ee()->config->_global_vars['site_label'];

//Global config settings (Base URL)
$var = ee()->config->config['base_url'];

//User variables (alternate method)
$var = ee()->session->userdata['group_id'];
  • I was just updating an answer as i found it and you beat me to it! Thanks muchly though this is exactly what i was looking for!
    – Derple
    Commented Apr 13, 2015 at 16:09
  • 1
    That's totally how I got around this in the past, I just couldn't reach deep enough in my brainspace. Mondays. Good job!
    – jrothafer
    Commented Apr 13, 2015 at 16:10
  • 1
    Glad to help, I know what you mean jchrono-battle about Mondays. I've been having a head-muck all day on Magento overloading. It makes EE "remember how to do..." relatively easy!!
    – Blatant
    Commented Apr 13, 2015 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.