Page 1 of 1

Random Member

Posted: 2. July 2009 13:47
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

Re: Random Member

Posted: 2. July 2009 16:21
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?

Re: Random Member

Posted: 2. July 2009 16:59
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

Re: Random Member

Posted: 2. July 2009 17:50
by MrBaseball34
Yes, I will modify it for those fields and post the code.

Re: Random Member

Posted: 2. July 2009 18:03
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?

Re: Random Member

Posted: 2. July 2009 19:37
by MrBaseball34
I will add comments to show you how to modify it on your own.

Re: Random Member

Posted: 3. July 2009 17:26
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.

Re: Random Member

Posted: 3. July 2009 19:23
by girlintrouble
Thanks for the update, Im really excited (blush)

Re: Random Member

Posted: 7. July 2009 20:48
by MrBaseball34
Still working on it, please be patient, I do this in my spare time.

Re: Random Member

Posted: 10. July 2009 23:03
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 ;-)

Re: Random Member

Posted: 12. July 2009 06:36
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>

Re: Random Member

Posted: 12. July 2009 15:23
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

Re: Random Member

Posted: 17. July 2009 21:07
by MrBaseball34
So, did it work for you?

Re: Random Member

Posted: 19. July 2009 03:53
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

Re: Random Member

Posted: 20. September 2010 17:06
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 :)