Dextro Energy Posted September 6, 2021 Posted September 6, 2021 (edited) Question 1: How would I check if a user is in a Moderator group? I understand that the below exists: \IPS\Member::loggedIn()->isAdmin() Is there an equivalent for Moderator? What is it? - I understand I could just check all Group IDs that I know are Moderators but that means hardcoding and it isn't very elegant, I put an example below of that: {{if \IPS\Member::loggedIn()->inGroup( array( 28, 15, 6 ) )}} Groups 28, 15 and 6 can view this. (All of which are Moderator groups) {{endif}} But... I don't really want to do this. I would much rather something like an "isMod" check that would update itself, rather than needing me to put IDs every time a moderator group is added, or removed. Question 2: How can I check all of the things available for me to use for an object in IPS such as \IPS\Member::loggedIn()? What documentation exists to show me all the methods, etc. if any? Thank you! Edited September 6, 2021 by Liloz01
opentype Posted September 6, 2021 Posted September 6, 2021 3 minutes ago, Liloz01 said: How can I check all of the things available for me to use for an object in IPS such as \IPS\Member::loggedIn()? The best option is to look at the corresponding file which sets these functions. In this case, this would be: system → Member → Member.php Daniel F 1
Daniel F Posted September 6, 2021 Posted September 6, 2021 You could use IPS\Member::loggedIn()->modPermission() to see if the member has any mod permissionsÂ
Dextro Energy Posted September 6, 2021 Author Posted September 6, 2021 8 hours ago, opentype said: The best option is to look at the corresponding file which sets these functions. In this case, this would be: system → Member → Member.php Thanks for letting me know. I wish some type of easier to search system existed though. Even just a PDF, lol.  8 hours ago, Daniel F said: You could use IPS\Member::loggedIn()->modPermission() to see if the member has any mod permissions This will do the job! Thank you.
Solution IPCommerceFan Posted September 7, 2021 Solution Posted September 7, 2021  On 9/6/2021 at 12:33 AM, Liloz01 said: Question 2: How can I check all of the things available for me to use for an object in IPS such as \IPS\Member::loggedIn()? What documentation exists to show me all the methods, etc. if any? @Liloz01, I'd say the comments in the source files are a pretty good form of documentation. I use a 3rd party app called FileLocator aka Agent Ransack to search the source files for these sorts of things: We knew exactly what to search for in this case, but a search for just "moderator" would have ultimately led to the same result since the comment includes the word in line 72. I'm no programmer, but this tool along with a good IDE like PhpStorm have made all the difference in developing my own plugins as the need arises! As for how to know what you can do with \IPS\Member::loggedIn, I'd search for "\IPS\Member" and browse around to see how it is used, especially as it pertains to functions which accept a Member object. (To find it used strictly in functions I'd search for "@param   \IPS\Member") e.g.:  \IPS\Member::loggedIn()->memberPostCount() /** * Post count for member * * @param \IPS\Member $member The member * @param bool $includeNonPostCountIncreasing If FALSE, will skip any posts which would not cause the user's post count to increase * @param bool $includeHiddenAndPendingApproval If FALSE, will skip any hidden posts, or posts pending approval * @return int */ public static function memberPostCount( \IPS\Member $member, bool $includeNonPostCountIncreasing = FALSE, bool $includeHiddenAndPendingApproval = TRUE ) Hope that helps! Dextro Energy 1
Martin A. Posted September 8, 2021 Posted September 8, 2021 (edited) On 9/7/2021 at 5:02 PM, IPCommerceFan said: I'm no programmer, but this tool along with a good IDE like PhpStorm have made all the difference in developing my own plugins as the need arises! You don't need that other program if you already have and use PhpStorm. Ctrl + Shift + F will give you an equal solution 🙂 Edited September 8, 2021 by Martin A. IPCommerceFan 1
IPCommerceFan Posted September 8, 2021 Posted September 8, 2021 Oh man, thanks @Martin A.! I wasn't aware PhpStorm could do that! Martin A. 1
Recommended Posts