Twitter SMFHacks Facebook SMFHacks SMFHacks.com
** Home Forum Index Hacks Products Login Register Search
Welcome, Guest. Please login or register.
May 18, 2013, 04:10:05 am

Login with username, password and session length
Members
Total Members: 10755
Latest: henrywilliams0173
Stats
Total Posts: 32348
Total Topics: 5473
Online Today: 50
Online Ever: 2482
(April 09, 2011, 07:02:45 pm)
Users Online
Users: 0
Guests: 44
Total: 44
+ 
|-+ 
| |-+ 
| | |-+ 
| | | |-+ 
0 Members and 1 Guest are viewing this topic. « previous next »
Pages: [1] Go Down Print
Author Topic: How to create a participation badge  (Read 923 times)
shuban
Badge Awards Customer
Full Member
*****
Offline Offline

Posts: 163


View Profile WWW
« 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?
Logged

SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« 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.
Logged
shuban
Badge Awards Customer
Full Member
*****
Offline Offline

Posts: 163


View Profile WWW
« 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?
Logged

SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« Reply #3 on: June 25, 2012, 12:56:15 pm »

A query like this should do it
Code:
SELECT count(distinct id_topic) as total from smf_messages where id_member =  ####memberidhere####
Logged
shuban
Badge Awards Customer
Full Member
*****
Offline Offline

Posts: 163


View Profile WWW
« Reply #4 on: June 25, 2012, 12:57:43 pm »

A query like this should do it
Code:
SELECT count(distinct id_topic) as total from smf_messages where id_member =  ####memberidhere####

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

SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« 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.
Logged
shuban
Badge Awards Customer
Full Member
*****
Offline Offline

Posts: 163


View Profile WWW
« Reply #6 on: June 25, 2012, 01:12:10 pm »

I tried this:

Code:
// 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 Undecided What am I doing wrong?
Logged

SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« 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 &&
Logged
SMFHacks
Administrator
Hero Member
*****
Offline Offline

Posts: 10987


View Profile
« 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...
Logged
shuban
Badge Awards Customer
Full Member
*****
Offline Offline

Posts: 163


View Profile WWW
« Reply #9 on: June 25, 2012, 01:23:46 pm »

I think this did the trick, for now Wink Roll Eyes

Code:
// 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;
}
}
}
Logged

Pages: [1] Go Up Print 
« previous next »
Jump to:  

Recent
[May 16, 2013, 10:13:46 pm]

[May 15, 2013, 11:32:14 pm]

[May 15, 2013, 11:31:24 pm]

[May 12, 2013, 09:10:43 am]

[May 10, 2013, 03:49:55 am]

[May 07, 2013, 07:12:40 pm]

[May 07, 2013, 02:37:14 pm]

[May 06, 2013, 10:29:56 pm]

[May 04, 2013, 03:22:01 pm]

[May 04, 2013, 01:08:57 pm]
Random Picture
Donate to SMFHacks.com
Help Support the SMFHacks.com mod making.
Powered by SMF 1.1.18 | SMF © 2013, Simple Machines
TinyPortal v0.9.7 © Bloc
SMF and SimpleMachines are registered trademarks of Simple Machines. SMFHacks.com is not affiliated with nor endorsed by Simple Machines.
Page created in 1.264 seconds with 22 queries.