sk8er_boi Posted April 18, 2016 Posted April 18, 2016 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?
Ilya Hoilik Posted April 21, 2016 Posted April 21, 2016 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 }
sk8er_boi Posted April 23, 2016 Author Posted April 23, 2016 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
Nathan Explosion Posted April 23, 2016 Posted April 23, 2016 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."; }
sk8er_boi Posted April 23, 2016 Author Posted April 23, 2016 Thank you a lot. I'm almost there. How can i get the member id?
sk8er_boi Posted April 23, 2016 Author Posted April 23, 2016 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.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.