Random Member

Current Version: 1.0.6
Released: 09.01.10
Forum rules
Before creating a new support thread, please take a look in the board3 Portal FAQ and use the search!
Many questions have already been answered.
Locked

Topic author
girlintrouble
Active Member
Posts: 15
Joined: 17. June 2009 12:15
phpBB.com User: girlintrouble
Location: UK

Random Member

Post by girlintrouble »

Your Portal Version: 1.0.0RC3
Your phpBB Type: Standard phpBB3
MODs installed: Yes
Your knowledge: Basic Knowledge

What have you done before the problem was there?
No Problem

What have you already tryed to solve the problem?


Description and Message
How does the random member thing work?
Is it possible to exclude members with zero posts or less than 5 posts? I would also like to use a custom profile field to allow users to include or exclude themselves from this. Would also be good to show the users profile and interests as well as their avatar.
I sit possible to do this?
Thank you
User avatar

MrBaseball34
Valued Contributor
Posts: 64
Joined: 25. June 2009 00:15
phpBB.de User: MB34

Re: Random Member

Post by MrBaseball34 »

girlintrouble wrote:<SNIP>
How does the random member thing work?
Is it possible to exclude members with zero posts or less than 5 posts? I would also like to use a custom profile field to allow users to include or exclude themselves from this. Would also be good to show the users profile and interests as well as their avatar.
I sit possible to do this?
Thank you
To filter out users with < 5 posts, change the SQL in the file root/portal/block/random_member.php, Add a WHERE clause
similar to : (for default)

Code: Select all

   $sql = 'SELECT *
   			FROM ' . USERS_TABLE . '
			WHERE user_type <> ' . USER_IGNORE . '
			AND user_type <> ' . USER_INACTIVE . '
			AND user_posts >= 5
			ORDER BY RAND()';
It should already show the user's avatar, if they have one. It already shows these user values:
user_rank
user_regdate
user_from
user_website
user_occ

What other profile info do you require?
MrBaseball34
Hook 'em Horns
Image
2005 College Football National Champions
2005 College Baseball National Champions

Topic author
girlintrouble
Active Member
Posts: 15
Joined: 17. June 2009 12:15
phpBB.com User: girlintrouble
Location: UK

Re: Random Member

Post by girlintrouble »

Thanks!
Well if I create a custom profile say with a boolean value Yes / No called showuser then can I add something to the sql which will not show users who have opted out ie showuser = no?
Additional fields:
Occupation
Location
Website


Is it possible? ;) Thanks
User avatar

MrBaseball34
Valued Contributor
Posts: 64
Joined: 25. June 2009 00:15
phpBB.de User: MB34

Re: Random Member

Post by MrBaseball34 »

Yes, I will modify it for those fields and post the code.
MrBaseball34
Hook 'em Horns
Image
2005 College Football National Champions
2005 College Baseball National Champions

Topic author
girlintrouble
Active Member
Posts: 15
Joined: 17. June 2009 12:15
phpBB.com User: girlintrouble
Location: UK

Re: Random Member

Post by girlintrouble »

Thank you!!!!
What if I wanted to add any other custom profile field of extra information ion the futire to display will it be obvious how to add that too?
User avatar

MrBaseball34
Valued Contributor
Posts: 64
Joined: 25. June 2009 00:15
phpBB.de User: MB34

Re: Random Member

Post by MrBaseball34 »

I will add comments to show you how to modify it on your own.
MrBaseball34
Hook 'em Horns
Image
2005 College Football National Champions
2005 College Baseball National Champions
User avatar

MrBaseball34
Valued Contributor
Posts: 64
Joined: 25. June 2009 00:15
phpBB.de User: MB34

Re: Random Member

Post by MrBaseball34 »

girlintrouble wrote:Thanks!
Well if I create a custom profile say with a boolean value Yes / No called showuser then can I add something to the sql which will not show users who have opted out ie showuser = no?
Additional fields:
Occupation
Location
Website


Is it possible? ;) Thanks
Those columns are already being shown in the Random member block.
I am working on showing a checkbox in the User's Profile to "opt-out" of the Random Member block. Running into problems getting the values correctly from the DB otherwise it looks good.
MrBaseball34
Hook 'em Horns
Image
2005 College Football National Champions
2005 College Baseball National Champions

Topic author
girlintrouble
Active Member
Posts: 15
Joined: 17. June 2009 12:15
phpBB.com User: girlintrouble
Location: UK

Re: Random Member

Post by girlintrouble »

Thanks for the update, Im really excited (blush)
User avatar

MrBaseball34
Valued Contributor
Posts: 64
Joined: 25. June 2009 00:15
phpBB.de User: MB34

Re: Random Member

Post by MrBaseball34 »

Still working on it, please be patient, I do this in my spare time.
MrBaseball34
Hook 'em Horns
Image
2005 College Football National Champions
2005 College Baseball National Champions

Topic author
girlintrouble
Active Member
Posts: 15
Joined: 17. June 2009 12:15
phpBB.com User: girlintrouble
Location: UK

Re: Random Member

Post by girlintrouble »

Thanks for the update. 8-)
I was thinking it would be better to exclude members who had not logged in for the last month. I guess that would be possbile through the sql too.
Hope thats ok ;-)
User avatar

MrBaseball34
Valued Contributor
Posts: 64
Joined: 25. June 2009 00:15
phpBB.de User: MB34

Re: Random Member

Post by MrBaseball34 »

Ok, here are the changes required to be able to allow the user to select if
they want to not be shown in the Random User Block and to also not show
them if they so choose... Sorry it took me so long but I had problems with
getting the options in the profile to work correctly.
God Luck.

Be sure to add the a column to your users table named

Code: Select all

user_showuser VARCHAR(3) NOT NULL default 'off'
This code change limits the result set to include only the users that
want to be seen in the Block.
random_member.php:
In the section with your SQL, add this to the existing WHERE clause
(on the line before the ORDER BY:

Code: Select all

  AND user_showuser = 'on'
And, if you want to limit to only users with > 5 posts, add this to the
WHERE clause:

Code: Select all

  AND user_posts > 5
I'll look into how to limit to only users that have logged in in the last month.

Now, to add the option for the user to select if they want to be seen
in the Random User block, make these changes:
language/<lang>/common.php

Code: Select all

  $lang = array_merge($lang, array(
    <!-  SNIPPED CODE -->
    'SETTINGS'  => 'Settings',
    'SHOWUSER'  => 'Show In Random User Block',
    <!-  SNIPPED CODE -->
  )); 
includes/ucp/ucp_main:

Code: Select all

  $template->assign_vars(array(
    'USER_COLOR'      => (!empty($user->data['user_colour'])) ? $user->data['user_colour'] : '',
    <!-  SNIPPED CODE -->
    'SHOWUSER'        => ($user->data['user_showuser'] == 'on' ? 'checked="checked"' : '')
  ));
includes/ucp/ucp_profile:

Code: Select all

  $data = array(
    'icq'             => request_var('icq', $user->data['user_icq']),
    <!-  SNIPPED CODE -->
    'showuser'        => utf8_normalize_nfc(request_var('showuser', 'off')),
  );

<!-  SNIPPED CODE -->

  if ($submit)
  {
    $validate_array = array(
      'icq'          => array(
                        array('string', true, 3, 15),
                        array('match', true, '#^[0-9]+$#i')),
      <!-  SNIPPED CODE -->
      'showuser'     => array('string', true, 2, 3),
  );          );

<!-  SNIPPED CODE -->

  'showuser'         => utf8_normalize_nfc(request_var('showuser', 'off')),

<!-  SNIPPED CODE -->

  $sql_ary = array(
    'user_icq'       => $data['icq'],
    <!-  SNIPPED CODE -->
    'user_showuser'  => $data['showuser']
  );

<!-  SNIPPED CODE -->

  $template->assign_vars(array(
    'ERROR'          => (sizeof($error)) ? implode('<br />', $error) : '',
    <!-  SNIPPED CODE -->
    'SHOWUSER'       => (($data['showuser'] =='on') ? 'checked="checked"' : ''),
  ));
styles/<style>/template/ucp_profile_profile_info.html:

Code: Select all

<tr>
  <td class="row1" width="35%"><b class="genmed">{L_SHOWUSER}: </b></td>
  <td class="row2"><input type="checkbox" class="radio" name="showuser" value="on" {SHOWUSER}/></td>
</tr>
MrBaseball34
Hook 'em Horns
Image
2005 College Football National Champions
2005 College Baseball National Champions

Topic author
girlintrouble
Active Member
Posts: 15
Joined: 17. June 2009 12:15
phpBB.com User: girlintrouble
Location: UK

Re: Random Member

Post by girlintrouble »

8-) 8-) 8-) 8-) 8-) 8-) 8-) Wicked will try this very soon and let you know how I get on.
Thanks so much, I think this is a really good enhancement to the random member display.
Really happy. :D
User avatar

MrBaseball34
Valued Contributor
Posts: 64
Joined: 25. June 2009 00:15
phpBB.de User: MB34

Re: Random Member

Post by MrBaseball34 »

So, did it work for you?
MrBaseball34
Hook 'em Horns
Image
2005 College Football National Champions
2005 College Baseball National Champions

Topic author
girlintrouble
Active Member
Posts: 15
Joined: 17. June 2009 12:15
phpBB.com User: girlintrouble
Location: UK

Re: Random Member

Post by girlintrouble »

Had some other problems. Waiting to install the board 3 and then this great addition. Will certainly report back and tell you how great it is no fear!
:D

diesusi
Active Member
Posts: 4
Joined: 17. September 2010 16:51
phpBB.de User: diesusi

Re: Random Member

Post by diesusi »

girlintrouble wrote:Thank you!!!!
What if I wanted to add any other custom profile field of extra information ion the futire to display will it be obvious how to add that too?
I'd like to do the same.

Can anybody help me? Please :)
Locked

Return to “board3 Portal 1.0.x - English Support”