View Full Version : hook location newthread
ageurtse
01-28-2014, 05:10 PM
Is there a hook location when i push the post button after writing a new thread.
I can't find it, is it there or do i have to modify somthing so i could get a hook location there.
There's probably more than one hook you could use. What do you want to do when the button's pressed?
ageurtse
01-28-2014, 05:34 PM
i wan't the person be redirect to a different page, where the user has to fill in some more information. after the info is validated the post has to be released.
if the validation fails the post has to be canceld.
Well, when you're submitting a new post, it goes to newpost.php with do=postthread, so maybe you could use hook newthread_start with code like:
if ($_REQUEST['do'] == 'postthread' && /* check for validation not done */)
{
show validation page (i.e., render a template and call print_output(), or do a redirect)
}
I hope that makes sense.
Actually, on second thought it might be easier to use hook newthread_post_start. You wouldn't need to do the check for $_REQUEST['do'] == 'postthread' because it's been done already, and the form fields from the new thread page have been cleaned already (you might want to look at newthread.php and search for newthread_post_start to see what's going on there).
ageurtse
01-28-2014, 06:06 PM
When i use that hook location it is called on the start of an new thread, how can it now that i hit the post button?
When i use that hook location it is called on the start of an new thread, how can it now that i hit the post button?
Most of the php scripts in vb perform more than one function. newpost.php is called to display the form for a new thread, and also to post the thread (and a few other functions). The "do" parameter is used to tell the script which function is being performed. You might want to take a look at newpost.php to see what's going on. You can see there are different sections, for instance, around line 100 is this code:
// ############################### start post thread ###############################
if ($_POST['do'] == 'postthread')
{
which is the start of the code that posts a new thread. And a little farther down is this:
// ############################### start new thread ###############################
if ($_REQUEST['do'] == 'newthread')
{
which starts the section that displays the form for a new thread.
I hope this answers you question - I'm not completely sure I understood.
ageurtse
01-28-2014, 06:54 PM
hmmmm i can't get it to work
this is what i have done but no pop-up.
hook location newthread_start and newthread_post_start
and this is the code
if ($foruminfo['forumid'] == 356 && $_REQUEST['do'] == 'postthread')
{
$message = 'This is a message.';
echo "<SCRIPT>
alert('$message');
</SCRIPT>";
}
when i leave $_REQUEST['do'] == 'postthread' away, there is a pop-up only on the hook location newthread_start.
i now i do something wrong or use the wrong hook. but i don't know what.
I tried it and it seems to work. Are we talking about the same button? Try adding another message as an "else" to your if, and display $_REQUEST['do'] in the message.
ageurtse
01-28-2014, 08:59 PM
Well it is the button beside the preview button called post new thread.
Right, that's what I thought. If removing $_REQUEST['do'] == 'postthread' makes it work, then $_REQUEST['do'] must be something else at that point. If you can figure out what it is we might be able to figure out why you're having a problem.
tbworld
01-28-2014, 09:32 PM
@KH99 pretty well summed it up. Maybe you wanted 'newthread' instead of 'postthread' so your not checking the right response?
Add to your plugin at the top for a simple check or in the else part as @Kh99 suggested.
var_dump($foruminfo['forumid']);
var_dump($_REQUEST['do']);
ageurtse
01-29-2014, 05:41 AM
@tbworld, ai put them there, tryed several hook locations but non worked for me.
i will try to somehow find a different hook location to get this done. for now work calls
tbworld
01-29-2014, 06:08 AM
Three things you might try...
1.) See if you have another plugin that is using that hook, and interfering.
2.) Check your PHP error file for an eval error on that hook.
3.) Temporarily embed the hook code in newpost.php to check your code without the hook.
ageurtse
01-30-2014, 05:18 PM
Hello,
i have findout that this hook location looks to work for me
showthread post_start
but it is always called, even with a follow up post. How can i check that it is a new post.
ageurtse
02-01-2014, 01:35 PM
I'm looking ad the php code from the file newthread.php there is a hook newthread_post_start
It look's to me that this hook should accesed when a user hit the button submit new thread.
but when i set this hook location in my plugin, nothing happens. why isn't it running.
there should be a popup message for testing purpose, when ttry other hook location the popup is shown. so that part of the code is oke.
please need help on this.
--------------- Added 1391339902 at 1391339902 ---------------
I really need some help with this, i tryed hole night to get my plugin to popup a new screen/message. but nothing works not one hook location seems to do the job.
I would have a new screen in between hitting the post button and actualy post the data.
in this screen it should be possible to cancel the post or to allow the post.
How could this be done ?
vBulletin® v3.8.12 by vBS, Copyright ©2000-2025, vBulletin Solutions Inc.