Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

+- Forum Stats

Members
Total Members: 4260
Latest: Verrick
New This Month: 3
New This Week: 0
New Today: 0
Stats
Total Posts: 43301
Total Topics: 7525
Most Online Today: 102
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 72
Total: 72

Author Topic: How to create a participation badge  (Read 4125 times)

0 Members and 1 Guest are viewing this topic.

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
How to create a participation badge
« on: June 24, 2012, 09:31:21 pm »
I'd like to create a participation badge where you're given a badge based on how many times a member has particpated in the forum.

For instance, a member could have 50 posts, but those posts were only made in 7 topics total. Therefore, they have participated 7 times.

Or, in the same way, the member may have 50 posts and 3 topics, so it would be 10 times participated.

How could this be done?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16455
    • View Profile
Re: How to create a participation badge
« Reply #1 on: June 25, 2012, 11:53:21 am »
What do you mean by participated? Number of topics?

Either way it would be done by an SQL query to get the criteria that you are basing the participation on.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: How to create a participation badge
« Reply #2 on: June 25, 2012, 12:49:39 pm »
What do you mean by participated? Number of topics?

Either way it would be done by an SQL query to get the criteria that you are basing the participation on.

Participation, as in, how many topics you've been a part of.

Like, you could have 6 posts in total, but those 6 posts were made in 2 topics. So essentially, you've only participated in two discussions.

Do you get what I mean?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16455
    • View Profile
Re: How to create a participation badge
« Reply #3 on: June 25, 2012, 12:56:15 pm »
A query like this should do it
Code: [Select]
SELECT count(distinct id_topic) as total from smf_messages where id_member =  ####memberidhere####
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: How to create a participation badge
« Reply #4 on: June 25, 2012, 12:57:43 pm »
A query like this should do it
Code: [Select]
SELECT count(distinct id_topic) as total from smf_messages where id_member =  ####memberidhere####

YES! You're right... ;D But, where would I place this? And how could I implement this in badgeawards.php?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16455
    • View Profile
Re: How to create a participation badge
« Reply #5 on: June 25, 2012, 01:00:23 pm »
It would be in the same area as the topic starter badges/post badges in the badgewards php file.
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: How to create a participation badge
« Reply #6 on: June 25, 2012, 01:12:10 pm »
I tried this:

Code: [Select]
// Participation Awards

$badgeAction = 'participation10';
if ($memberContext[$memberID]['topic_count'] >= 10 && !in_array($badgeAction,$currentBadges))
{

$result = db_query("
SELECT COUNT(distinct id_topic) AS total FROM {$db_prefix}smf_messages WHERE ID_MEMBER = $memberID
", __FILE__, __LINE__); 
$totalRow = mysql_fetch_assoc($result);
if ($totalRow['total'] > 0)
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[]  = $badgeAction;
}
}
}

But nothing happened :-\ What am I doing wrong?

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16455
    • View Profile
Re: How to create a participation badge
« Reply #7 on: June 25, 2012, 01:14:48 pm »
Get rid of $memberContext[$memberID]['topic_count'] >= 10 &&
Or change to
$memberContext[$memberID][posts'] > 0 &&
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline SMFHacks

  • Administrator
  • Hero Member
  • *****
  • Posts: 16455
    • View Profile
Re: How to create a participation badge
« Reply #8 on: June 25, 2012, 01:15:30 pm »
Right now the way you have it coded will give anyone who ever made a post a badge... not sure if that's what you want...

if ($totalRow['total'] > 0)


That part above is key you can have different badges depending on a total number...
Get your Forum Ranked! at https://www.forumrankings.net - find out how your forum compares with others!

Like What I do? Support me at https://www.patreon.com/vbgamer45/

Offline shuban

  • Hero Member
  • *****
  • Posts: 665
    • View Profile
    • Biology Forums
Re: How to create a participation badge
« Reply #9 on: June 25, 2012, 01:23:46 pm »
I think this did the trick, for now ;) ::)

Code: [Select]
// Participation Awards // Still needs work

$badgeAction = 'participation10';
if ($memberContext[$memberID]['posts'] != 0 && !in_array($badgeAction,$currentBadges))
{

$result = db_query("
SELECT COUNT(distinct id_topic) AS total FROM {$db_prefix}messages WHERE ID_MEMBER = $memberID
", __FILE__, __LINE__); 
$totalRow = mysql_fetch_assoc($result);
if ($totalRow['total'] >= 10)
{
$badgeID = GetBadgeIDByAction($badgeAction);
$ret = AddBadgeToMember($memberID,$badgeID,false);
if ($ret == true)
{
$currentBadges[] = $badgeAction;
$newBadges[]  = $badgeAction;
}
}
}

 

Related Topics

  Subject / Started by Replies Last post
4 Replies
6055 Views
Last post July 11, 2007, 03:05:09 pm
by princess38
2 Replies
6786 Views
Last post March 11, 2009, 04:25:21 pm
by Wegg
2 Replies
3905 Views
Last post March 25, 2009, 02:52:09 am
by Wajalot
0 Replies
7979 Views
Last post August 23, 2010, 10:29:50 am
by SMFHacks
1 Replies
3710 Views
Last post June 07, 2012, 05:40:14 pm
by SMFHacks

+- Recent Topics

Pretty Urls extras by SMFHacks
May 13, 2024, 10:28:54 am

Mod question by Verrick
May 11, 2024, 02:42:50 pm

i have paid but cant download ad pro. by SMFHacks
May 02, 2024, 11:29:38 pm

Please Help! by SMFHacks
April 17, 2024, 08:04:55 am

Rate own images by fvlog19
April 11, 2024, 10:56:53 am

Tidy Child Boards on 2.1.4 by SMFHacks
April 04, 2024, 03:54:12 pm

Problems SMF 2.0.19 > 2.1.4 SMF Gallery Pro - Recents Images to overall header by Michel68
March 30, 2024, 12:41:08 pm

Can't DROP 'id_member'; check that column/key exists Datei: by SMFHacks
March 30, 2024, 11:58:20 am

No thumbnails on new uploads by Tonyvic
March 29, 2024, 06:26:18 am

Display the Contact Page for guests by SMFHacks
March 27, 2024, 10:55:43 am

Powered by EzPortal