XF 2.1 Template error: Cannot call method isMemberOf on a non-object (NULL)

thomje114

Member
Hi all,

We're getting this error and I'm not exactly sure where to find the code that's messing up:

Code:
#0 [internal function]: XF\Template\Templater->handleTemplateError()
#1 src/XF/Template/Templater.php(984): trigger_error()
#2 internal_data/code_cache/templates/l1/s16/public/forumer_userbanners.php(101): XF\Template\Templater->method()
#3 src/XF/Template/Templater.php(1315): XF\Template\Templater->{closure}()
#4 src/XF/Template/Templater.php(1388): XF\Template\Templater->renderTemplate()
#5 internal_data/code_cache/templates/l1/s16/public/message_macros.php(98): XF\Template\Templater->includeTemplate()
#6 src/XF/Template/Templater.php(701): XF\Template\Templater->{closure}()
#7 internal_data/code_cache/templates/l1/s16/public/post_macros.php(46): XF\Template\Templater->callMacro()
#8 src/XF/Template/Templater.php(701): XF\Template\Templater->{closure}()
#9 internal_data/code_cache/templates/l1/s16/public/thread_view.php(617): XF\Template\Templater->callMacro()
#10 src/XF/Template/Templater.php(1315): XF\Template\Templater->{closure}()
#11 src/XF/Template/Template.php(24): XF\Template\Templater->renderTemplate()
#12 src/XF/Mvc/Renderer/Html.php(48): XF\Template\Template->render()
#13 src/XF/Mvc/Dispatcher.php(458): XF\Mvc\Renderer\Html->renderView()
#14 src/XF/Mvc/Dispatcher.php(440): XF\Mvc\Dispatcher->renderView()
#15 src/XF/Mvc/Dispatcher.php(400): XF\Mvc\Dispatcher->renderReply()
#16 src/XF/Mvc/Dispatcher.php(58): XF\Mvc\Dispatcher->render()
#17 src/XF/App.php(2190): XF\Mvc\Dispatcher->run()
#18 src/XF.php(391): XF\App->run()
#19 index.php(20): XF::runApp()
#20 {main}

Could someone point me in the right direction?
 

thomje114

Member
Oops, sorry.

Here's the error message:

  • ErrorException: Template error: Cannot call method isMemberOf on a non-object (NULL)
  • src/XF/Template/Templater.php:984
  • Generated by: Unknown account
  • May 31, 2020 at 10:58 AM
 

Chris D

XenForo developer
Staff member
It seems to be generated by a template that isn't ours. I'm not sure if forumer_userbanners (the name of the problematic template) provides any clues to identify which add-on it is.
 

thomje114

Member
It seems to be generated by a template that isn't ours. I'm not sure if forumer_userbanners (the name of the problematic template) provides any clues to identify which add-on it is.

It's a template that we created - which is:

<snipped>

I've looked over everything and I can't figure out why it's throwing errors?
 
Last edited:

Chris D

XenForo developer
Staff member
It will be because, at some point, $user isn't an object that contains the isMemberOf method.

Does it work in most cases but occasionally you get this error? If so, then the code might be being called in some contexts where there isn't a $user value.
 
Top