Facebook 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4287
Latest: ArromGomwef
New This Month: 1
New This Week: 0
New Today: 0
Stats
Total Posts: 43773
Total Topics: 7600
Most Online Today: 68
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 60
Total: 60

Author Topic: How to create a participation badge  (Read 4815 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: 16664
    • 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: 16664
    • 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: 16664
    • 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: 16664
    • 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: 16664
    • 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
6338 Views
Last post July 11, 2007, 03:05:09 pm
by princess38
2 Replies
6875 Views
Last post March 11, 2009, 04:25:21 pm
by Wegg
2 Replies
4122 Views
Last post March 25, 2009, 02:52:09 am
by Wajalot
0 Replies
8175 Views
Last post August 23, 2010, 10:29:50 am
by SMFHacks
1 Replies
3905 Views
Last post June 07, 2012, 05:40:14 pm
by SMFHacks

+- Recent Topics

Sorted FTP Import Directory by Senkusha
April 24, 2025, 01:20:23 pm

Default [Additional] Membergroups upon Registration by Senkusha
April 24, 2025, 06:20:28 am

Trying to access array offset on null by Michel68
April 22, 2025, 11:47:22 pm

Search results items per page? by SMFHacks
April 18, 2025, 04:12:23 pm

Suggestions and request by Senkusha
April 03, 2025, 02:30:43 pm

How does a member add a Classified Listing? by SMFHacks
March 28, 2025, 08:05:50 pm

Auto converting to webp or AVIF by [chrisB]
March 28, 2025, 01:46:00 pm

Thumbnail creation settings by SMFHacks
March 28, 2025, 12:42:51 pm

Cookie consent banner? by SMFHacks
March 26, 2025, 02:19:49 pm

Bulk Upload Frozen by SMFHacks
March 26, 2025, 07:58:13 am

Powered by EzPortal