Jump to content

Get current user ID inside forums block

Featured Replies

Posted

Hello,

I'm using PHP & TXT Widget and I'm needing to insert an iframe that needs to include the ID of the current logged-in user in the URL.

As with this plugin I can use PHP, how can I print the ID of the actual user?

 

Thanks a lot!

  • Author

I was able to achieve it. I was using the wrong code block. Needed to activate the "Active PHP widget" in plugin settings, then get the "PHP Code" block (that appeared after activating the setting) and get it to layout.

After that, this did it:

<?php
$logged_in = \IPS\Member::loggedIn();

if (!empty($logged_in)) {
    echo '<iframe src="http://example.com/' . $logged_in->member_id . '" width="100%" height="400" frameborder="0"></iframe>';
}
?>

 

Archived

This topic is now archived and is closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.