vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=251)
-   -   if post count conditional (https://vborg.vbsupport.ru/showthread.php?t=317953)

hilaryl 03-25-2015 12:44 AM

if post count conditional
 
Hi everyone,

Fairly sure this is a simple request, but can't quite figure out how to do it.

I want to include a conditional statement in a users postbit if the user has made more then X posts. I know I can get the total number of posts from the user using this {vb:raw post.posts}

That returns a number like 1,784

How can use that variable in a conditional though?

Essentially 'if {vb:raw post.posts} > 1000' Do this.....

Can anyone help out? What's the correct syntax?

Cheers,
hilaryl

Elite_360_ 03-25-2015 01:53 AM

HTML Code:

<vb:if condition="$post['posts'] > 1000">
Code Here
</vb:if>


hilaryl 03-25-2015 04:00 AM

Thanks for the code.

Unfortunately this isn't working though, and I'm fairly sure it's because '$post['posts']' is equal to a number with a comma in it. As in it's equal to '1,060'.

How can I turn '1,060' into '1060' so I can compare the numbers?

Elite_360_ 03-25-2015 07:21 PM

Make a new plugin

Product = vBulletin

Hook Location = postbit_display_complete

Title = what ever you want for a tiltle

Execution Order = 5

Plugin PHP Code

PHP Code:


$post
['new_user_posts'] = str_replace(','''$post['posts']); 


Plugin is Active = check to Yes


New Condition

HTML Code:


<vb:if condition="$post['new_user_posts'] > 1000">
Code Here
</vb:if>


hilaryl 03-25-2015 10:28 PM

Fantastic - thanks for being so thorough with your explanation.

I'll give it a go shortly and let you know how I go.

Thanks,
hilaryl

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

Works like a charm!

Actually ended up tweaking it a bit and added what I wanted into another template_hook so I don't have to alter the post_bit template.

Full plugin code below:

HTML Code:

$new_user_posts = str_replace(',', '', $post['posts']);

if ($new_user_posts > 500) {
$template_hook['postbit_userinfo_right_after_posts'] .= '<!--<dt></dt><dd>' . $new_user_posts . '</dd>-->';
}



All times are GMT. The time now is 05:34 AM.

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.01055 seconds
  • Memory Usage 1,723KB
  • 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
  • (3)bbcode_html_printable
  • (1)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (5)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