1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Hook right before trying to post a new thread in a forum

Discussion in 'XenForo Development Discussions' started by Vincent Gabriel, Jan 11, 2014.

  1. Vincent Gabriel

    Vincent Gabriel Active Member

    Is there a way to hook into the posting new thread process without editing files?

    Thank You.
     
  2. Liam W

    Liam W Well-Known Member

    Use the class proxy system
     
  3. Vincent Gabriel

    Vincent Gabriel Active Member

    This is very unhelpful. I am aware of the proxy class system, but need little bit more than that.
     
  4. Liam W

    Liam W Well-Known Member

    There are a few guides posted that explain how to use it...

    Basically, create two classes:

    XX_Addon
    XX_ControllerPublic_Thread extends XFCP_XX_ControllerPublic_Thread

    in the XX_Addon class you'll have a static method:

    PHP:
    public static function extend($class, array &$extend)
    {
    if (
    $class == 'XenForo_ControllerPublic_Thread')
    {
    $extend[] = 'XX_ControllerPublic_Thread';
    }
    }
    in the XX_ControllerPublic_Thread you'll want to add the public function actionCreateThread() method to extend the thread create action.

    You'll then have to listen to a code event listener, the 'extend_class_controller' one, with the class as XX_Addon and the method as extend.

    Your class will now be in the extension tree for the thread controller, allowing you to extend the functions.

    Make sure you call the parent function!

    Liam
     
  5. Vincent Gabriel

    Vincent Gabriel Active Member

    @Liam W

    Thank You. That helped a lot.

    I also run a search and have been doing this for a couple of days now and was pretty successful on other questions that i had. I just couldn't get a good answer regarding my case here. I'll give this a try thanks again.
     
  6. Vincent Gabriel

    Vincent Gabriel Active Member

    That worked. The only thing is that the actionCreateThread is located under the ControllerPublic_Forum class not the ControllerPublic_Thread class.

    Thank You.
     

Share This Page