Jump to content

Getting ipb user info from php script

Featured Replies

Posted

I have a php script which I want only the people in specified groups can use. I could do this with ipb 3 sdk. Is there any alternatives for ips4?

Can you clarify, you want to put PHP-code into theme templates? If so, you can use this construction:

{{if \IPS\Member::loggedIn()->inGroup( 5 )}}
	This code will be displayed if user is in group with ID = 5
{{endif}}

Otherwise (in your app/plugin) you should use this:

if ( \IPS\Member::loggedIn()->inGroup( 5 ) )
{
	// This code will be displayed if user is in group with ID = 5
}
  • Author

No. I have a php script that I developed. I used IPB3SDK to check if a user can see a specific forum (means that user in a special group) and let him use the script.

Now that ipb3sdk isn't updated to ips 4, what other chances do i have to check if an user is logged to my forum and user has privileges?

 

sample code that i used

define('IPB_PATH', '');
require_once('../ipbsdk/SDKConfig.php');
$self = $_SERVER['PHP_SELF'];
$sdk = IPBSDK::instance();
$login = $sdk->getClass('login');
$member = $sdk->getClass('member');
$username = $sdk->memberData['members_display_name'];
$user_id = $sdk->memberData['member_id'];
//forum no 47 is the special forum which my VIP members can see.
$isVIP = $member->checkPermissions("view",  47);



if (isVIP==1){ 

blabla

 

Play with this....

<?php
require 'init.php';
\IPS\Session\Front::i();
$member = \IPS\Member::loggedIn();
// Say who it is
if ( $member->member_id )
{
	echo "{$member->name} is logged in.";
}
else
{
	echo "The user is not logged in.";
}

 

 

 

  • Author

Thank you a lot. I'm almost there. How can i get the member id?

$member->member_id
  • Author
10 minutes ago, Adriano Faria said:

$member->member_id

Tried that but

$user_id = $member->member_id;

throws 

Something went wrong. Please try again.

 

 

although it works when i try it on test script. strange.

Edited by sk8er_boi

Archived

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

Recently Browsing 0

  • No registered users viewing this page.