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

$user parameters - not all available

Discussion in 'XenForo Development Discussions' started by Chris D, Jun 24, 2012.

  1. Chris D

    Chris D XenForo Developer Staff Member

    I've created a helper that works great for displaying a user's age in the message_user_info.

    Only problem is, I can't get it to honour the option in a user's preferences which is $user['show_dob_year'].

    Of all the $user parameters that are available to message_user_info (and loads are that I can use), that isn't one of them.

    If there's no way of passing that parameter to the template, is there anything else I can do? Is there some sort of function I can write that will check it?

    Something so simple is proving incredibly difficult.

    Annoyingly, $visitor['show_dob_year'] is available, but that's useless for respecting a user's privacy.
  2. Chris D

    Chris D XenForo Developer Staff Member

    It's because the $user parameters are mapped from $message in the message template when the message_user_info template is called.

    But still hoping there's a solution.
  3. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The user options are not selected for posts. You need to modify this function:


    Add the red code:

    	protected function _getPostFetchOptions(array $thread, array $forum)
    		$postFetchOptions = $this->_getPostModel()->getPermissionBasedPostFetchOptions($thread, $forum) + array(
    			'join' => XenForo_Model_Post::FETCH_USER | XenForo_Model_Post::FETCH_USER_PROFILE | XenForo_Model_Post::FETCH_USER_OPTIONS,
    			'likeUserId' => XenForo_Visitor::getUserId()
    		if (!empty($postFetchOptions['deleted']))
    			$postFetchOptions['join'] |= XenForo_Model_Post::FETCH_DELETION_LOG;
    		return $postFetchOptions;
    Of course this can also be extended with an addon instead of editing the file.
    dwdmadmac and Chris D like this.
  4. Chris D

    Chris D XenForo Developer Staff Member

    That's working great.

    Thank you Mr. Genius :D

Share This Page