0

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?

<?php
  $uid = "{member_id}";
?>
10
  • What EE version? I just tested it on 2.9.3 and it worked exactly as expected.
    – jrothafer
    Apr 13 '15 at 15:28
  • 2.7.0 @jchrono-battle
    – Derple
    Apr 13 '15 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
    Apr 13 '15 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
    Apr 13 '15 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
    Apr 13 '15 at 15:58
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'];
3
  • 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
    Apr 13 '15 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
    Apr 13 '15 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
    Apr 13 '15 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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