Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 General Discussions
  #1  
Old 07-02-2014, 11:28 PM
grom815 grom815 is offline
 
Join Date: Mar 2011
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Is there a way of having two post counts per user?

Im looking for either a product, or a way of doing this myself.
What I want is to have a user have two post-counts. One being an inflated one, and one being a "real one".

For example,
If User1 has 20 posts on my forum, but I edit his post count to be 50, in his postbit and profile, it will say 50.
I want to have his profile and postbit say 50, just like it is.
However, in his profile only, underneath 'Total Posts', I want there to be 'Posts in these forums', where the value is 20.
When he makes a new post, I want the postbit and 'Total Posts' to go to 51 like normal, and the 'Posts in these forums' to go up also to 21. I want the posts per day to be calculated using the 21 posts.

Or maybe make a duplicate of the 'Total Posts' and add an offset to it and change the postbit to have that value?

Any way I can do this and not screw everything up?

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

Anyone?


Maybe I can create a custom non-user-editable field, and put their offset post count in there. For the example, I will name this field 'Offset'.
So if a user has 20 posts on my forum, his 'Total Posts' will say 20. As admin, I would edit his 'Offset' field to say 50.
Then, I would edit the postbit to show 'Total Posts' + 'Offset' for post count. In this example, it would show Postcount: 70.

Is math like this even possible?


I'm open to any ideas....
Is there a tutorial on adding custom fields in MySQL and interfacing them with vBulletin?
Maybe I can add a 'TotalPostsPlusOffset' column in the same table that has the postcount. Then, when I make a change to a user's 'Offset' field, it would run an update query on that user and add the 'Postcount' and 'Offset' columns.
Reply With Quote
  #2  
Old 07-03-2014, 11:25 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by grom815 View Post
Maybe I can create a custom non-user-editable field, and put their offset post count in there. For the example, I will name this field 'Offset'.
So if a user has 20 posts on my forum, his 'Total Posts' will say 20. As admin, I would edit his 'Offset' field to say 50.
Then, I would edit the postbit to show 'Total Posts' + 'Offset' for post count. In this example, it would show Postcount: 70.

Is math like this even possible?
I think this would be easiest, if just changing the postbit display is enough. There's a minor complication in that the posts number is formatted as a string and the original integer is not saved, so there's no easy way to recalculate it after that. But what you might do is create a plugin using hook postbit_display_start and create your own "adjusted posts" value in $post, then edit your postbit (or postbit_legacy) to use the new value.

For example, if your non-user-editable field is field7, then maybe the plugin code is:
Code:
$post['adjusted_posts'] = vb_number_format($post['posts'] + $post['field7']);
Then in the postbit template, change {vb:raw post.posts} to {vb:raw post.adjusted_posts}.

But IIRC, the profile field has to at least be publicly readable or else you'll find $post['field7'] will be empty.
Reply With Quote
Благодарность от:
Lynne
  #3  
Old 07-04-2014, 12:23 AM
grom815 grom815 is offline
 
Join Date: Mar 2011
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by kh99 View Post
I think this would be easiest, if just changing the postbit display is enough. There's a minor complication in that the posts number is formatted as a string and the original integer is not saved, so there's no easy way to recalculate it after that. But what you might do is create a plugin using hook postbit_display_start and create your own "adjusted posts" value in $post, then edit your postbit (or postbit_legacy) to use the new value.

For example, if your non-user-editable field is field7, then maybe the plugin code is:
Code:
$post['adjusted_posts'] = vb_number_format($post['posts'] + $post['field7']);
Then in the postbit template, change {vb:raw post.posts} to {vb:raw post.adjusted_posts}.

But IIRC, the profile field has to at least be publicly readable or else you'll find $post['field7'] will be empty.

Holy hell, that was so easy...
You are my hero!

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

That worked just fine, but now I'm trying to add that same post count to the sidebar on the member profile sidebar.

In 'memberinfo_block_ministats', there is the code:
<dl class="stats">
<dt>{vb:rawphrase total_posts}</dt>
<dd> {vb:raw prepared.posts}</dd>
</dl>

I am trying to get the adjusted_posts value previously calculated to show here as well.
I tried using the same code using the 'member_build_blocks_start' hook, and changing 'prepared.posts' to 'post.adjusted_posts', but it didn't work.

What was I supposed to do differently?

Thanks!
Reply With Quote
  #4  
Old 07-04-2014, 07:01 PM
vbresults vbresults is offline
 
Join Date: Apr 2009
Posts: 687
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No need to edit any templates (this will be a pain in the ass later) --

Hook: postbit_display_complete
PHP Code:
// Overwrite the original post count, alleviating the need for a template edit
$post['posts'] = vb_number_format(intval(str_replace(","""$posts['posts'])) + $posts['field7']); 
Hook: member_complete
PHP Code:
// Overwrite the original post count, alleviating the need for a template edit
$prepared['posts'] = vb_number_format(intval(str_replace(","""$prepared['posts'])) + $userinfo['field7']); 
Reply With Quote
Благодарность от:
kh99
  #5  
Old 07-04-2014, 07:36 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by vbresults View Post
No need to edit any templates (this will be a pain in the ass later) --

Hook: postbit_display_start
PHP Code:
// Overwrite the original post count, alleviating the need for a template edit
$post['posts'] = vb_number_format(intval(str_replace(","""$posts['posts'])) + $post['field7']); 
...
Yeah, I thought about it after I posted and realized that it wasn't really that hard to undo the number formatting - good call. Your code assumes the thousands separator is a comma, which is probably true for grom815, but to generalize it you could use $vbulletin->userinfo['lang_thousandsep'].

But it needs to use hook postbit_display_complete, and there's also a typo ($posts['post'] needs to be $post['posts']).
Reply With Quote
Благодарность от:
vbresults
  #6  
Old 07-04-2014, 09:22 PM
grom815 grom815 is offline
 
Join Date: Mar 2011
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks, but the first snippet worked, so I am going to leave it.

I added a plugin:
$prepared['posts'] = vb_number_format(intval(str_replace(",", "", $prepared['posts'])) + $userinfo['field7']);

with a hook 'member_complete'.

It did not do anything for the profile page. The post count is still the original post count.
Reply With Quote
  #7  
Old 07-11-2014, 11:45 PM
grom815 grom815 is offline
 
Join Date: Mar 2011
Posts: 13
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04840 seconds
  • Memory Usage 2,242KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (2)bbcode_code
  • (3)bbcode_php
  • (3)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (7)post_thanks_box
  • (3)post_thanks_box_bit
  • (7)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (3)post_thanks_postbit
  • (7)post_thanks_postbit_info
  • (7)postbit
  • (7)postbit_onlinestatus
  • (7)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.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/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • fetch_musername
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • post_thanks_function_fetch_thanks_bit_start
  • post_thanks_function_show_thanks_date_start
  • post_thanks_function_show_thanks_date_end
  • post_thanks_function_fetch_thanks_bit_end
  • post_thanks_function_fetch_post_thanks_template_start
  • post_thanks_function_fetch_post_thanks_template_end
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete