core-bundle/src/Resources/contao/dca/tl_member.php
public function switchUser($row, $href, $label, $title, $icon)
	{
		$blnCanSwitchUser = ($this->User->isAdmin || (!empty($this->User->amg) && \is_array($this->User->amg)));

		if (!$blnCanSwitchUser)
		{
			return '';
		}

		if (!$row['login'] || $row['username'] == '' || (!$this->User->isAdmin && \count(array_intersect(Contao\StringUtil::deserialize($row['groups'], true), $this->User->amg)) < 1))
		{
			return Contao\Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';
		}

		return '<a href="contao/preview.php?user='.rawurlencode($row['username']).'" title="'.Contao\StringUtil::specialchars($title).'" target="_blank">'.Contao\Image::getHtml($icon, $label).'</a> ';
	}
public function switchUser($row, $href, $label, $title, $icon)
	{
		$blnCanSwitchUser = ($this->User->isAdmin || (!empty($this->User->amg) && \is_array($this->User->amg)));

		if (!$blnCanSwitchUser)
		{
			return '';
		}

		if (!$row['login'] || $row['username'] == '' || (!$this->User->isAdmin && \count(array_intersect(Contao\StringUtil::deserialize($row['groups'], true), $this->User->amg)) < 1))
		{
			return Contao\Image::getHtml(preg_replace('/\.svg$/i', '_.svg', $icon)).' ';
		}

		return '<a href="contao/preview.php?user='.rawurlencode($row['username']).'" title="'.Contao\StringUtil::specialchars($title).'" target="_blank">'.Contao\Image::getHtml($icon, $label).'</a> ';
	}
Generate a "switch account" button and return it as string

@param array  $row
@param string $href
@param string $label
@param string $title
@param string $icon

@return string