USER LEVEL NOTIFICATION MOD
Posted 20 August 2003
Edited 20 August 2003 - Added subject line to email message, and new star count to message text
This MOD sends an email notification to the SuperAdmin whenever a user posts a message that brings them to the next user level threshhold. It requires two additions (additions only - no changes to existing code) to one file - inc_func_count.asp. This mod could be easily extended to include notification to all admins / moderators, or to the forum member reaching the new rank.
This MOD was created to help us avoid noticing when our members reached new ranks.
This MOD is compatible with my ADDITIONAL RANKS MOD, but it does not require that mod to work.
Ease of implementation (1-10, 10 hardest): 2
INC_FUNC_COUNT.ASP
1. Find the doUCount sub (around line 61) and add the code in red
immediately before the end sub statement:
sub doUCount(sUser_Name)
'## Forum_SQL - Update Total Post for user
strSql = "UPDATE " & strMemberTablePrefix & "MEMBERS "
strSql = strSql & " SET M_POSTS = M_POSTS + 1 "
strSql = strSql & " WHERE " & strDBNTSQLName & " = '" & ChkString(sUser_Name, "SQLString") & "'"
my_Conn.Execute (strSql),,adCmdText + adExecuteNoRecords
'## USER LEVEL NOTIFICATION MOD
if strEmail = "1" then
strSql = "SELECT M_POSTS FROM " & strMemberTablePrefix & "MEMBERS WHERE " & strDBNTSQLName & " = '" & ChkString(sUser_Name, "SQLString") & "'"
set upostcount = my_Conn.Execute (strSql)
upost_count = upostcount(0).Value
upost_count = cInt(upost_count)
upostcount.Close
set upostcount = NOTHING
doURankNotification sUser_Name, upost_count
end if
end sub
2. Just before the final %> of the file, add the following code: (note - if you have not added the ADDITIONAL RANKS MOD, then the last
five elseif clauses in the doURankNotification sub are not necessary and can optionally be removed. Leaving them in should not affect the operation of this MOD.)
'## USER LEVEL NOTIFICATION MOD
sub doURankNotification(uName, uPosts)
if cInt(uPosts) = cInt(intRankLevel1) then
doSendNewRankNotification uName, uPosts, 1, strRankLevel1
elseif cInt(uPosts) = cInt(intRankLevel2) then
doSendNewRankNotification uName, uPosts, 2, strRankLevel2
elseif cInt(uPosts) = cInt(intRankLevel3) then
doSendNewRankNotification uName, uPosts, 3, strRankLevel3
elseif cInt(uPosts) = cInt(intRankLevel4) then
doSendNewRankNotification uName, uPosts, 4, strRankLevel4
elseif cInt(uPosts) = cInt(intRankLevel5) then
doSendNewRankNotification uName, uPosts, 5, strRankLevel5
elseif cInt(uPosts) = cInt(intRankLevel6) then
doSendNewRankNotification uName, uPosts, 6, strRankLevel6
elseif cInt(uPosts) = cInt(intRankLevel7) then
doSendNewRankNotification uName, uPosts, 7, strRankLevel7
elseif cInt(uPosts) = cInt(intRankLevel8) then
doSendNewRankNotification uName, uPosts, 8, strRankLevel8
elseif cInt(uPosts) = cInt(intRankLevel9) then
doSendNewRankNotification uName, uPosts, 9, strRankLevel9
elseif cInt(uPosts) = Cint(intRankLevelA) then
doSendNewRankNotification uName, uPosts, 10, strRankLevelA
end if
end sub
sub doSendNewRankNotification(member_name, post_count, new_level_num, new_level_name)
strSql = "SELECT M_EMAIL FROM " & strMemberTablePrefix & "MEMBERS WHERE MEMBER_ID=" & intAdminMemberID
set rsAdmin = my_conn.Execute (strSql)
strRecipients = rsAdmin(0).Value
rsAdmin.Close
set rsAdmin = NOTHING
if strRecipients = "" then Exit Sub
strSubject = strForumTitle & " Member Level Notification"
strMessage = "Hello Admin" & vbNewline & vbNewline & "Forum member "
strMessage = strMessage & member_name & " now has " & post_count & " posts, has reached a new member level of " & _
new_level_num & " stars, and now has the title '" & new_level_name & "'"
%>
<!--#INCLUDE FILE="inc_mail.asp" -->
<%
end sub
Upload your new version of inc_func_count.asp, and you are done.