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

about the new markThreadRead()

Discussion in 'XenForo Development Discussions' started by DarkSign, Mar 10, 2012.

  1. DarkSign

    DarkSign Active Member

    Hello devs.

    I was testing my add-on, the Auto Lock Threads, in the new XenForo, and then it gave me this error:

    This is how I am trying to get the userID and pass to the markThreadRead() method:

    //just the relevant part of the code
    $visitorId XenForo_Visitor::getUserId();
    //after some more lines

    So, for the message, the method requires an array. I will study the new core code later, when I have time, but I need a fix for that, so can someone explain how can I get the Argument 4 (the user id, in previous version) correctly?
  2. Bob

    Bob Well-Known Member

    the 4th argument needs the entire viewing user array not just the ID...

    do this instead..

    //just the relevant part of the code
    $visitor XenForo_Visitor::getInstance();
    //after some more lines
  3. DarkSign

    DarkSign Active Member

    I tested it, but it seems to be returning an Object and not an Array.

    the following error:

    Also, to keep things up with the $visitor object, how do I extract the ID, that is being used by other calls, and those are working?
  4. Bob

    Bob Well-Known Member

    ah ya, this should do the trick for you.

    $viewingUser = XenForo_Visitor::getInstance()->toArray();

    $viewingUser['user_id']; is the view users user ID.

    Do a Zend_Debug::dump(); to see everything within the object or array.
    DarkSign likes this.
  5. DarkSign

    DarkSign Active Member

    And now that solved this small issue with my code. It's working on 1.1! I will update the resource now, thank you very much for now :)

Share This Page