Login  |  Register
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome, Guest. Please login or register.
Did you miss your activation email?

October 04, 2022, 11:34:15 AM

Login with username, password and session length
Members
  • Total Members: 3848
  • Latest: rrolle
Stats
  • Total Posts: 193513
  • Total Topics: 21092
  • Online today: 58
  • Online ever: 3540
  • (September 02, 2022, 06:38:54 PM)
Users Online
Users: 1
Guests: 47
Total: 48

Author Topic: Managing groups able to see blocks  (Read 2935 times)

0 Members and 1 Guest are viewing this topic.

OriginalP

  • Guest
Managing groups able to see blocks
« on: March 21, 2007, 03:18:37 PM »
Hi all,

with "Block Manager" panel (under "TinyPortal section") i can choose membergroups that are able to see blocks, but i can choose only from "Regular groups" and not from "Post count based groups".

I want some blocks to be visible only to members that have a minimum of posts.

Is it possible?

Thanks in advance.
« Last Edit: January 03, 2008, 06:38:58 AM by OriginalP »

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Managing groups able to see blocks
« Reply #1 on: March 21, 2007, 03:22:13 PM »
Currently TP does not use Post based groups. You may be able to code a block to only show to certain post based groups, but I'm unaware of where that can be called from. I'll search and see if I can find any info.

OriginalP

  • Guest
Re: Managing groups able to see blocks
« Reply #2 on: March 21, 2007, 03:34:38 PM »
Thanks for your quick reply ;)

i specify that managing post count based groups is not strictly necessary, since i "only" want some blocks to be visible only to members that have a minimum of posts (i.e. > 50)

I use TP v0.9.7

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Managing groups able to see blocks
« Reply #3 on: March 21, 2007, 03:48:03 PM »
In a php block try something like this. (Replace the number 4 with your group ID). You can get the ID number by hovering over the group in your admin panel.


global $user_info;
if(
$user_info['groups'] == 4)
{
echo 
'all the html or php you need in here';
}

OriginalP

  • Guest
Re: Managing groups able to see blocks
« Reply #4 on: March 21, 2007, 06:18:39 PM »
Tnx for the code!

i tried using it creating a new phpblock

global $user_info;
if(
$user_info['groups'] == && $user_info['groups'] == 5)
{
echo 
"first html code"
}
else
{
echo 
'second html code';
}


but it does not seem to function and always the "second html code" is shown: i tried using an account with over 6000 posts and another one with 35 posts, after changing the number of posts required for Newbie group (4) and Jr Member group (5) to 0 and 40; both are able to see the block even if the account with 35 posts should not (35<40)

what's wrong?

i'm very newbie with php, but i try to add a line

echo $user_info['groups'];

and the output is Array
Can this info help?

Thank you very much

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Managing groups able to see blocks
« Reply #5 on: March 21, 2007, 07:59:55 PM »
I'm not sure on the exact synax for this. But I'm wondering if this line should look like this:
if(($user_info['groups'] == 4) && ($user_info['groups'] == 5))

You do know that what the above says, If user belongs to group4 AND group5. So if both situations does not exist it will always display or else statement. Perhaps you meant to do || (or) instead of && (and). Which means that either can exist instead of both.

OriginalP

  • Guest
Re: Managing groups able to see blocks
« Reply #6 on: March 22, 2007, 02:48:13 AM »
you are right, i would have used || (or) instead of && (and)

if(($user_info['groups'] == 4) && ($user_info['groups'] == 5))
(the () are not necessary)

with the help of a friend of mine i added these lines

$n=count($user_info['groups']);
for (
$i=0$i<$n$i++) {
  echo 
$user_info['groups'][$i];
}

to show every single value of the array

For me the output is 18323 because i belong to Admin group (1), Hero Member (8), Test (32); i don't know what the final number 3 correspond to, since there is no group with ID_group = 3
For the other account, Jr Member (5), i receive 05; i don't know why there is an initial zero for the same reason

Now i suppose i have to check if every single value of the array matches 4 or 5

Thanks a lot for the support
« Last Edit: March 22, 2007, 02:50:56 AM by OriginalP »

OriginalP

  • Guest
Re: Managing groups able to see blocks
« Reply #7 on: March 22, 2007, 06:53:57 AM »
Problem solved with this code

if($user_info['posts'] <= number_of_posts_required_here)

;)

Offline IchBin

  • Friends
  • *
  • Posts: 16231
Re: Managing groups able to see blocks
« Reply #8 on: March 22, 2007, 01:56:19 PM »
You wanna see whats inside $user_info just do this in a phpbox block
global $user_info;
echo 
'<pre>'print_r($user_info),'</pre>';