View Full Version : Auto-assign thread prefix when posting a new thread
James Birkett
09-29-2009, 05:27 PM
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:
if($foruminfo['forumid'] == 41){
$newpost['prefixid'] = 'Pending';
}
Yes my prefix ID is "Pending". I am using the newthread_post_complete hook.
Line 443 is:
$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:
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):
$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)...
$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! :)
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.