vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB4 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=252)
-   -   hook location newthread (https://vborg.vbsupport.ru/showthread.php?t=307626)

ageurtse 01-28-2014 05:10 PM

hook location newthread
 
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.

kh99 01-28-2014 05:14 PM

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.

kh99 01-28-2014 05:46 PM

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:
Code:

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.

kh99 01-28-2014 05:56 PM

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?

kh99 01-28-2014 06:21 PM

Quote:

Originally Posted by ageurtse (Post 2477542)
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:
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:
Code:

// ############################### 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
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.

kh99 01-28-2014 07:56 PM

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.

kh99 01-28-2014 09:11 PM

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.
Code:

  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 [DATE]1391339902[/DATE] at [TIME]1391339902[/TIME] ---------------

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 ?


All times are GMT. The time now is 09:14 PM.

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.01162 seconds
  • Memory Usage 1,749KB
  • 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_code_printable
  • (1)bbcode_quote_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (16)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