Facebook  Twitter 

SMFHacks.com

+-

SMFHacks.com

+- User Information

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

+- Forum Stats

Members
Total Members: 4229
Latest: Ghost
New This Month: 3
New This Week: 0
New Today: 0
Stats
Total Posts: 43074
Total Topics: 7493
Most Online Today: 108
Most Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Members: 0
Guests: 35
Total: 35

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

+- Recent Topics

Version 6.1.6 issues by davejo
Today at 02:21:44 pm

Follow / Follower Mod? by SMFHacks
September 23, 2023, 08:44:44 am

Looking for a good video player by replayuk
September 23, 2023, 12:17:39 am

[Mod]Discord Web Hooks by SMFHacks
September 22, 2023, 03:57:28 pm

SMF 2.1.4 Search by Anmer
September 22, 2023, 01:55:15 pm

Error in thise mode by Ghost
September 15, 2023, 08:42:24 am

Gallery Selection List Order by mickjav
September 07, 2023, 12:46:31 pm

[Mod]Tidy Child Boards 2.0 by Norwinjose
September 02, 2023, 11:42:54 am

PrettyUrls SEO Pro: Unable to submit sitemap to google search conmsole by SMFHacks
August 31, 2023, 10:55:22 am

PrettyURL - SEO4SMF Rewrites? by SMFHacks
August 28, 2023, 06:35:33 pm

Powered by EzPortal