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

How to modify $visitor instance in visitor_setup?

Discussion in 'XenForo Development Discussions' started by tyteen4a03, May 22, 2013.

  1. tyteen4a03

    tyteen4a03 Well-Known Member

    I want to do something to $visitor->_user in visitor_setup, however, I'm getting Indirect modification of overloaded property has no effect errors.

    How do I properly do this?
  2. Sadik B

    Sadik B Well-Known Member

    You should post your full visitor_setup code.
  3. tyteen4a03

    tyteen4a03 Well-Known Member

    To reproduce the error just do anything to the $visitor object.

    If you're asking for the actual function it should do, I have none - I’m just asking if this is possible.
  4. xf_phantom

    xf_phantom Well-Known Member

    it's working for me

    public static function injectIgnoredUsers(XenForo_Visitor &$visitor){
    $visitor['my_new_foo'] = 'we\'re here';
    $visitor['ignoredUsers'] = self::getIgnoredUsers();
    Sim likes this.
  5. tyteen4a03

    tyteen4a03 Well-Known Member

    Oh! I was modifying $visitor->_user. My bad :p
    Sim likes this.
  6. xf_phantom

    xf_phantom Well-Known Member

    $visitor->_user won't work because $_user is protected

    $visitor->offsetSet('name', 'value');

    should work too

Share This Page