HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Callback Issues in plugin. Your expertise Needed.


preg_replace_callback($search, "Myfunction", $text);

I can make a callback if my Myfunction resides outside of the class TestPlugin extends Gdn_Plugin {  ...}


          function Myfunction($variable) {    

I can't find a solution.  Anybody know one.    

I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Best Answer

Answers

  • TimTim Vanilla Staff
    Answer ✓

    preg_replace_callback($search, array($this, 'Myfunction'), $text);

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • TimTim Vanilla Staff

    More info here: http://php.net/manual/en/language.types.callable.php

    A method of an instantiated object is passed as an array containing an object at index 0 and the method name at index 1.

    Vanilla Forums COO [GitHub, Twitter, About.me]

  • thx much Tim. I'll give it a try.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

  • @Tim - your suggestion worked perfectly.

    Now you can add the autolink plugin to the vanilla forum site itself :).

    Don't know how it would affect performance if there are alot of tags or if if it would be too cluttered. But it would save time adding links to wiki and bonk, etc and provide clickable tags throughout the comments.

    I may not provide the completed solution you might desire, but I do try to provide honest suggestions to help you solve your issue.

Sign In or Register to comment.