vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 General Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=111)
-   -   Auto-assign thread prefix when posting a new thread (https://vborg.vbsupport.ru/showthread.php?t=224211)

James Birkett 09-29-2009 05:27 PM

Auto-assign thread prefix when posting a new thread
 
Evening all,

I was wondering if there's a method of automatically assigning a thread prefix to a new thread when it is submitted. I don't want the user to select a prefix, I want a default one to be assigned.

Reason:
I'm creating a forum with 3 prefixes. Accepted, Rejected and Pending.
I want "Pending" to be appended onto any thread that is submitted in that forum so I can sort through the pending/accepted/rejected by sorting the prefixes.

I am guessing it would be possible on the newthread_complete hook; however any help is greatly appreciated.

Thanks.

Lynne 09-29-2009 07:03 PM

Yeah, I'd use a hook and add it in there. I would use newthead_post_complete hook as you suggested since it is after the prefix would be defined for the thread (so you can over-ride what is entered) and before the post is saved. You can read the code right before that hook to see how to set it.

James Birkett 09-29-2009 08:03 PM

Hello again,

I have the following code:
PHP Code:

if($foruminfo['forumid'] == 41){
$newpost['prefixid'] = 'Pending';


Yes my prefix ID is "Pending". I am using the newthread_post_complete hook.

Line 443 is:
PHP Code:

$prefix_options fetch_prefix_html($foruminfo['forumid'], $newpost['prefixid'], true); 

So I am guessing I am using the right syntax.

The hook I am using is line 271 and the $newpost['prefixid'] is defined on line 170:
PHP Code:

    if (can_use_prefix($vbulletin->GPC['prefixid']))
    {
        
$newpost['prefixid'] =& $vbulletin->GPC['prefixid'];
    } 

Could someone help me out?

Thanks again.


EDIT: I have made sure that the prefix is assigned to that forum, so the issue isn't that the prefix isn't there.

Lynne 09-29-2009 10:16 PM

Whoops... I just took another look and the post is actually guild on line 213 (how did I miss that?), so you need to set it prior to that line, so I guess newthread_post_start instead.

James Birkett 09-30-2009 01:48 PM

Thanks for your reply Lynne. I still have the issue of the prefix not appending though. Using the same above code.

There doesn't seem to be a variable for the prefix before line 143 (the hook)? Except in the phrasegroups.

I will have another look around, thanks for anything you can dig up though.

Lynne 09-30-2009 02:18 PM

If you use newthread_post_start, then you actually will have to do something like this so it doesn't get overwritten (add your condition):
PHP Code:

$vbulletin->GPC['prefixid'] = 'Pending'


James Birkett 09-30-2009 02:25 PM

Thanks Lynne!

I do have another issue however:
If I have set regular users not able to use prefixes in that forum, it doesn't append a prefix.

Any way around this?

Lynne 09-30-2009 03:11 PM

Try this (with your condition around it)...

PHP Code:

$vbulletin->GPC['prefixid'] = 'Pending'
$newpost['prefixid'] =& $vbulletin->GPC['prefixid']; 


This way, the prefixid gets set here, and then it can be rewritten later on if they have privs. If they don't have privs, it doesn't get set in that other line, but you made sure it was set here anyway. Hopefully that works.

James Birkett 09-30-2009 03:55 PM

Thanks Lynne! You're truly a star :)

Lynne 09-30-2009 04:35 PM

Glad you got it working! :)


All times are GMT. The time now is 04:02 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.01319 seconds
  • Memory Usage 1,736KB
  • 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
  • (5)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (10)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