• 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

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.

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.

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.