vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Testing for user never posted? (https://vborg.vbsupport.ru/showthread.php?t=296022)

JamesAB 03-12-2013 03:29 PM

Testing for user never posted?
 
I'm working on a mod in attachment.php

I know $vbulletin->userinfo['posts'] could be '0' (zero) even if a user has posted before but their posts were deleted or are in a forum that doesn't count posts.

What's the best way to test if a user has never posted before?

Would testing $vbulletin->userinfo['lastpost'] work? If they have never posted before would this value be NULL or '0' (zero)?

Or is there a better way to definitively test if a user has never even tried to make a single post in the past?

Thanks for your help,
James

squidsk 03-12-2013 04:05 PM

None of those will actually work, since in theory a user could have posted and have had all their posts hard deleted in which case no record of any posts will exist. Short of changing the db by adding a field to user which is a boolean that gets set when they first make a post.

JamesAB 03-12-2013 06:41 PM

Quote:

Originally Posted by squidsk (Post 2409517)
None of those will actually work, since in theory a user could have posted and have had all their posts hard deleted in which case no record of any posts will exist. Short of changing the db by adding a field to user which is a boolean that gets set when they first make a post.

Okay. How about when a new user is created? What is the initial value of $vbulletin->userinfo['lastpost'] ?

And what would be the value of $vbulletin->userinfo['lastpost'] after a user's posts have been hard deleted?

Maybe I can find a compromise that would work.

Thanks,
James

--------------- Added [DATE]1363145263[/DATE] at [TIME]1363145263[/TIME] ---------------

Okay. I did some testing and found something that should work for me.

When a user firsts posts the value for $vbulletin->userinfo['lastpost'] changes from '0' to a unix timestamp. Even if that post gets hard deleted, the value of $vbulletin->userinfo['lastpost'] will not revert to '0'. It stays set to the last updated unix timestamp.

This seems to be an option for testing if a user has never posted:
PHP Code:

if ($vbulletin->userinfo['lastpost'] < 1

It works for me.


All times are GMT. The time now is 10:00 PM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00986 seconds
  • Memory Usage 1,719KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)bbcode_php_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (3)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete