Show online status

AndreaMarucci

Well-known member
It's possible to avoid the fact that the users deselect the "Show Online Status" checkbox so they'll result invisible to other users?

I would like that all my users show their status online and that nobody has this option...
 
I did this some time ago however I found that users were still being able to set themselves as invisible. For the life of me I couldn't find out how they were doing it and when asking them they didn't know either.

I ran into the same issue: whenever a user changes their account preferences, they are automatically set to invisible.
This can be seen in ACP -> Tools -> User Change logs, where Show online status and Show current activity change to No without the user even noticing.

Solution:
It's not enough to remove code from the templates like Jake explained in #6, you have to replace it in templates account_privacy and account_preferences with the following code:

Code:
<input type="hidden" name="visible" value="1" />
<input type="hidden" name="activity_visible" value="1" />

If you would like to mass-change all users, run the following SQL commands:
Code:
UPDATE `xf_user` SET visible=1;
UPDATE `xf_user` SET activity_visible=1;

Be aware that tech-savvy users will still be able to change their online preference if they edit the hidden fields in the browser inspector. The feature to change the visibility is not removed from the XenForo backend, it's just invisible in the user interface.
 
Here's the full code if you'd like to leave the visibility option available to admins and moderators.

Admin CP -> Appearance -> Templates -> account_privacy

Rich (BB code):
	<xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
	<!-- invisible mode only for admins and mods -->
	<dl class="ctrlUnit surplusLabel">
		<dt><label>{xen:phrase activity_display}:</label></dt>
		<dd>
			<ul>
				<li>
					<label for="ctrl_visible"><input type="checkbox" name="visible" value="1" id="ctrl_visible" class="OptOut Disabler" {xen:checked "{$visitor.visible}"} /> {xen:phrase show_your_online_status}</label>
					<p class="hint">{xen:phrase this_will_allow_other_people_to_see_when_you_online}</p>
					<ul id="ctrl_visible_Disabler">
						<li>
							<label><input type="checkbox" name="activity_visible" value="1" class="OptOut" {xen:checked $visitor.activity_visible} /> {xen:phrase show_your_current_activity}</label>
							<p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p>
						</li>
					</ul>
				</li>
			</ul>
		</dd>
	</dl>
	<xen:else />
	<input type="hidden" name="visible" value="1" />
	<input type="hidden" name="activity_visible" value="1" />
	</xen:if>

Admin CP -> Appearance -> Templates -> account_preferences

Rich (BB code):
				<xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
				<!-- invisible mode only for admins and mods -->
				<li>
					<label for="ctrl_visible"><input type="checkbox" name="visible" value="1" id="ctrl_visible" class="OptOut Disabler" {xen:checked "{$visitor.visible}"} /> {xen:phrase show_your_online_status}</label>
					<p class="hint">{xen:phrase this_will_allow_other_people_to_see_when_you_online}</p>
					<ul id="ctrl_visible_Disabler">
						<li>
							<label><input type="checkbox" name="activity_visible" value="1" class="OptOut" {xen:checked $visitor.activity_visible} /> {xen:phrase show_your_current_activity}</label>
							<p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p>
						</li>
					</ul>
				</li>
				<xen:else />
				<input type="hidden" name="visible" value="1" />
				<input type="hidden" name="activity_visible" value="1" />
				</xen:if>

Admin CP -> Appearance -> Templates -> navigation_visitor_tab

Rich (BB code):
				<xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
				<!-- invisible mode only for admins and mods -->
				<ul class="col1 blockLinksList">
					<li>
						<form action="{xen:link account/toggle-visibility}" method="post" class="AutoValidator visibilityForm">
							<label><input type="checkbox" name="visible" value="1" class="SubmitOnChange" {xen:checked $visitor.visible} />
								{xen:phrase show_online_status}</label>
							<input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
						</form>
					</li>
				</ul>
				</xen:if>

Tested on XF 1.5.23.
 
Top Bottom