Page 1 of 1

Passing User ID to Script

PostPosted: May 17th, 2010, 3:53 pm
by terrylad
I am sure this is something simple but I just can't seem to get passed it. I need to pass the User ID in a Java Script url but I keep getting the IP address instead. Here is the code:

<script type="text/javascript" src="http://xxxxxxxx?pub=xxxxx&subid="> & <?php echo S2MEMBER_CURRENT_USER_ID; ?> & <"></script>

I know nothing of javascript so I have no idea how exactly to do this. But it should be basic for someone out there who may know? I need to pass the &subid variable with the S2_MEMBER_CURRENT_USER_ID I am sure it's my sytax but I don't know the proper way. Any assistance would be greatly appreciated. Thanks

Terry Ladouceur

Re: Passing User ID to Script

PostPosted: May 17th, 2010, 6:12 pm
by DrMac
Hi

I think your syntax should be
Code: Select all
<script type="text/javascript" src="http://xxxxxxxx?pub=xxxxx&subid=<?php echo S2MEMBER_CURRENT_USER_ID; ?>"></script>


hope this helps

DrMac

Re: Passing User ID to Script

PostPosted: May 17th, 2010, 6:18 pm
by terrylad
Hi DrMac,

That is what I had originally tried as well but unfortunately this is what it outputs:

&subid=<%3Fphp+echo+S2MEMBER_CURRENT_USER_ID%3B+%3F>

It's like it's not running the actual php or something and if I do it outside of the quotes it send the IP address as the &subid. Still stumped. TTYL

Terry Ladouceur

Re: Passing User ID to Script

PostPosted: May 19th, 2010, 4:27 am
by Jason Caldwell
It looks to me like your code is being mangled by the WordPress® Visual Editor, or by internal WordPress® filters. You'll probably need to put this into your theme, and not paste it into a Post/Page. Check your theme directory for the header.php file. The code should be inserted like this:
Code: Select all
<?php echo S2MEMBER_CURRENT_USER_ID; ?>