News:

Want to get involved in developing SMF, then why not lend a hand on our github!

Main Menu

Special *annoying* message for members with 0 posts

Started by onijin, May 10, 2006, 01:07:17 PM

Previous topic - Next topic

onijin

Hi, my forums are plagued with lurkers, and I'm trying to put a stop to it.  So what I'm trying to do, is members with a post count of zero, have a message that is constantly  "reminding" them they have yet to post.  And have it disappear after the first post.

I've been messing with some codes, but can't seem to get the right combination.  I used:


// Have they posted yet?
{
if ($context['user']['posts'] = 0)

echo '

<tr>
<td colspan="2" width="100%" align="left" valign="top" class="windowbg2">
<span style="font-size: 100%;"> ', $txt['hello_member_ndt'], ' <b>', $context['user']['name'] , '

</span>!&nbsp;&nbsp;<br />You have never posted in the forums before! Make your first post today and say hello to our community in our <a href=/forum/index.php?board=48.0>Introductions</a> board.<br /><br /> Why not start with your first post today and become an active part of our community.  We are waiting for you!
</td>
</tr>';
}



in index.template.php
and the message is shown regardless of post count. obviously "if ($context['user']['posts'] = 0)" is wrong.  Any advice would be appreciated.  ^_^

ruzster

#1

if ($user_info['posts'] = 0)
 
                echo '
 
                               <tr>
                                    <td colspan="2" width="100%" align="left" valign="top" class="windowbg2">
                                         <span style="font-size: 100%;"> ', $txt['hello_member_ndt'], ' <b>', $context['user']['name'] , '
                                         
                </span>!&nbsp;&nbsp;<br />You have never posted in the forums before! Make your first post today and say hello to our community in our <a href=/forum/index.php?board=48.0>Introductions</a> board.<br /><br /> Why not start with your first post today and become an active part of our community.  We are waiting for you!
                                    </td>                         
                               </tr>';


Don't forget to add $user_info to your globals.

onijin

looks promising.  When my host comes back up, test it out, and let you know if it worked.  ~thanx~ ruz

winrules



winrules
SMF Developer
               
My Mods
Please do not PM me for support.


Harzem

if ($context['user']['posts'] = 0)

should be

if ($context['user']['posts'] == 0)

just a bit php experience ;)

edit: winrules, just 39 seconds faster than me :P

onijin

hmm... I even tried the double...


i tried

= 0
== 0
< 1

but =&== didn't show the message at all. (when post count was 0 on a new account)

< 1 however did... but didn't go away after the first post.

onijin

okay.

Added the $user_info to the global and used    if ($user_info['user']['posts'] == 0)

that gave me a parse error.

removed the global, changed it to   if ($context['user']['posts'] == 0)

and the message comes up.  0 posts and it's there.  However, after posting, still wont go away.

Harzem

Probably you coded the global declaration line incorrectly. Can you post that line?

onijin

   global $context, $settings, $options, $scripturl, $txt, $modSettings, $user_info;

Harzem


onijin

omg.  That worked.

LoL~!


sweeet~!  thanx guys~!   ^_^

Harzem


onijin

heh~!

thanks...

Kinda hard to get members

{insert shameless plug here}

Red-Omni

hey how can i get my hands on that mod/code ??

i need it for my forums as well , as i have the same issue with people joining and then not posting .

Alan S

yea me too! could some one post the full working code to it and where do you post it in the index.template.php?
Quote from: Eliana Tamerin on August 23, 2008, 04:10:10 PM
SMF 7 is where it gets good. That has time travel. You can go back and post before the guy who flamed you. :P

Alan S

Figured it out , so for anyone who wants it* ,

Index.template.php

Search For

global $context, $settings, $options, $scripturl, $txt, $modSettings;

Replace With

global $context, $settings, $options, $scripturl, $txt, $modSettings, $user_info;

Find

<div align="center" style="width: 90%; margin-left: auto; margin-right: auto; margin-top:10px; border: 0px solid;" class="middletext">
', $settings['custom_global_html'], '
</div>';


Add After

// Have they posted yet?
{
                     if ($user_info['posts'] == 0)

echo '

<tr>
<td colspan="2" width="100%" align="left" valign="top" class="windowbg2">
<span style="font-size: 100%;"> ', $txt['hello_member_ndt'], ' <b>', $context['user']['name'] , '

</span>!&nbsp;&nbsp;<br />REPLACE THIS TEXT WITH YOUR MESSAGE , HTML IS ALLOWED<br /><br />
</td>
</tr>';
}



I think this should be moved to the tips & tricks section , its fairly handy


*Code may change depending on theme , i used the index.template.php from the Dilbert MC theme
Quote from: Eliana Tamerin on August 23, 2008, 04:10:10 PM
SMF 7 is where it gets good. That has time travel. You can go back and post before the guy who flamed you. :P

onijin

actually... someone [Ruzster] made a mod (i've been using that).  Doesn't seem like it was approved for distrobution tho.  Works really well!  I like it.


Alan S

dammit ! lol , i spent the best part of 9 hours figuring it out!!!!!!!!! ah well.................at least i leart something....................
Quote from: Eliana Tamerin on August 23, 2008, 04:10:10 PM
SMF 7 is where it gets good. That has time travel. You can go back and post before the guy who flamed you. :P

^DooM^

Hi All,

I wonder if you can help me out. I am trying to do something similar to this on my forum except instead of displaying an annoying message if you dont post I want to ban a user if inactive for X number of days.

I have setup all the database settings i need and added the options in the admin panel etc. What I can't get my head around is how I can check the user has been offline for X Days.

In this annoying display message mods case it checks when they login. If in my case they login their X days inactive will be reset and will never be true. I thought about adding a manual button to loop through every user and check / add the ban but I would like this to be automated so I can set it and forget it. The other way I thought of doing it is run the check when I login but that seems like an ugly hack to me.

I have just thought of another way of doing this as I typed. By adding a small php script that I can run via crontab. Would this be a good way of doing what I need or is there a better way my tiny mind hasn't thought of.

Any help would be appreciated.

Kind regards,

Jon.
Never argue with an idiot, they will simply bring you down to their level and then beat you with experience

Advertisement: