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...
 
You would have to make some template edits to remove the checkbox from the account preferences and menu dropdown in the navigation bar.

Then you would need to manually set everyone to visible or run a query to update the database.
 
You can set the default for new users in your:

Admin CP -> Home -> Options -> User Registrations -> Default Registration Values -> Show online status

You can update the preferences of existing users by running this query on your database:

Code:
UPDATE xf_user
SET visible = 1

You can remove the option to change this setting by removing some code from the templates:

Admin CP -> Appearance -> Templates -> account_privacy

Code:
	<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" autofocus="autofocus" {xen:checked "{$visitor.visible}"} /> {xen:phrase show_your_online_status}</label> <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li>
			</ul>
		</dd>
	</dl>

Admin CP -> Appearance -> Templates -> account_preferences

Code:
	<dl class="ctrlUnit">
		<dt></dt>
		<dd><ul><li><label><input type="checkbox" name="visible" value="1" {xen:checked $visitor.visible} /> {xen:phrase show_your_online_status}</label> <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li></ul></dd>
	</dl>

Admin CP -> Appearance -> Templates -> navigation_visitor_tab

Code:
				<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>
 
You can set the default for new users in your:

Admin CP -> Home -> Options -> User Registrations -> Default Registration Values -> Show online status

You can update the preferences of existing users by running this query on your database:

Code:
UPDATE xf_user
SET visible = 1

You can remove the option to change this setting by removing some code from the templates:

Admin CP -> Appearance -> Templates -> account_privacy

Code:
<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" autofocus="autofocus" {xen:checked "{$visitor.visible}"} /> {xen:phrase show_your_online_status}</label> <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li>
</ul>
</dd>
</dl>

Admin CP -> Appearance -> Templates -> account_preferences

Code:
<dl class="ctrlUnit">
<dt></dt>
<dd><ul><li><label><input type="checkbox" name="visible" value="1" {xen:checked $visitor.visible} /> {xen:phrase show_your_online_status}</label> <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li></ul></dd>
</dl>

Admin CP -> Appearance -> Templates -> navigation_visitor_tab

Code:
<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>
Thank you for this, Jake.

Just curious, would using a conditional such as below allow this feature to be available only for Admins and Moderators?

How can I show content to Administrators and Moderators?
<xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
This content will show to Administrators and Moderators
</xen:if>
 
Thank you for this, Jake.

Just curious, would using a conditional such as below allow this feature to be available only for Admins and Moderators?

How can I show content to Administrators and Moderators?
<xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
This content will show to Administrators and Moderators
</xen:if>

Yes.
 
How can I show content to Administrators and Moderators?
<xen:if is="{$visitor.is_admin} OR {$visitor.is_moderator}">
This content will show to Administrators and Moderators
</xen:if>
How would you enable this for certain usergroups and not others? Not just Admins and Moderators.
 
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.

Finally I was able to track it down that when they changed their settings and saved them, the invisible setting was set true for some reason even though I had removed the code as Jake has pointed out above, so I ended up just changing the code in the account_preferences template to being hidden but true to make them still visible:
Code:
<li><input type="hidden" name="visible" value="1" /></li>

I actually extended that further by still allowing myself and my moderators to mark themselves as invisible but no one else by wrapping the code in an "if" conditional:
Code:
<xen:comment> IB added if and changed </xen:comment>
                <xen:if is="{xen:helper ismemberof, $visitor, 3, 4}">
                    <li><label><input type="checkbox" name="visible" value="1" {xen:checked $visitor.visible} />
                        {xen:phrase show_your_online_status}</label>
                        <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li>
                <xen:else />
                    <li><input type="hidden" name="visible" value="1" /></li>
                </xen:if>

So I am not sure if anyone else is finding their users still being able to become invisible or it was something strange that I have done but just in case this may help
 
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.

Finally I was able to track it down that when they changed their settings and saved them, the invisible setting was set true for some reason even though I had removed the code as Jake has pointed out above, so I ended up just changing the code in the account_preferences template to being hidden but true to make them still visible:
Code:
<li><input type="hidden" name="visible" value="1" checked="checked" /></li>

I actually extended that further by still allowing myself and my moderators to mark themselves as invisible but no one else by wrapping the code in an "if" conditional:
Code:
<xen:comment> IB added if and changed </xen:comment>
                <xen:if is="{xen:helper ismemberof, $visitor, 3, 4}">
                    <li><label><input type="checkbox" name="visible" value="1" {xen:checked $visitor.visible} />
                        {xen:phrase show_your_online_status}</label>
                        <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li>
                <xen:else />
                    <li><input type="hidden" name="visible" value="1" checked="checked" /></li>
                </xen:if>

So I am not sure if anyone else is finding their users still being able to become invisible or it was something strange that I have done but just in case this may help
I can confirm that this does happen, indeed.

Thank you for the tip, ibaker. I'll try it. :)
 
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.

Finally I was able to track it down that when they changed their settings and saved them, the invisible setting was set true for some reason even though I had removed the code as Jake has pointed out above, so I ended up just changing the code in the account_preferences template to being hidden but true to make them still visible:
Code:
<li><input type="hidden" name="visible" value="1" checked="checked" /></li>

I actually extended that further by still allowing myself and my moderators to mark themselves as invisible but no one else by wrapping the code in an "if" conditional:
Code:
<xen:comment> IB added if and changed </xen:comment>
                <xen:if is="{xen:helper ismemberof, $visitor, 3, 4}">
                    <li><label><input type="checkbox" name="visible" value="1" {xen:checked $visitor.visible} />
                        {xen:phrase show_your_online_status}</label>
                        <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li>
                <xen:else />
                    <li><input type="hidden" name="visible" value="1" checked="checked" /></li>
                </xen:if>

So I am not sure if anyone else is finding their users still being able to become invisible or it was something strange that I have done but just in case this may help


Could you please post the complete code of your account_preferences template? I messed something up, so I do need all lines of the template to make sure to have inserted it in the right line...

Is there no plugin available for deleting the unvisible option of users?
 
Could you please post the complete code of your account_preferences template? I messed something up, so I do need all lines of the template to make sure to have inserted it in the right line...
Code:
<xen:title>{xen:phrase browsing_preferences}</xen:title>
 
<xen:require css="account.css" />
 
<form method="post" class="xenForm _AutoValidator"
    action="{xen:link 'account/preferences-save'}"
    data-fieldValidatorUrl="{xen:link 'account/validate-field.json'}">
 
    <!--<h3 class="sectionHeader">{xen:phrase appearance}</h3>-->
    <xen:hook name="account_preferences_appearance">
    <xen:if is="{$canChangeStyle}"> 
        <dl class="ctrlUnit">
            <dt><label for="ctrl_style_id">{xen:phrase style}:</label></dt>
            <dd>
                <select name="style_id" class="textCtrl OptOut" id="ctrl_style_id" autofocus="on">
                    <option value="0">({xen:phrase use_default_style}: {$defaultStyle.title})</option>
                    <optgroup label="{xen:phrase styles}:">
                    <xen:foreach loop="$styles" key="$styleId" value="$style">
                        <xen:if is="{$style.user_selectable} OR {$visitor.is_admin}">
                            <option value="{$styleId}" class="{$style.depthClass}" {xen:selected '{$styleId} == {$visitor.style_id}'}>{$style.depthPrefix}{$style.title}</option>
                        </xen:if>
                    </xen:foreach>
                    </optgroup>
                </select>
                <p class="explain">{xen:phrase you_may_view_site_in_any_of_styles_provided_here}</p>
            </dd>
        </dl>
    <xen:else />
        <input type="hidden" name="style_id" value="{$visitor.style_id}" />
    </xen:if>
    </xen:hook>
 
 
    <h3 class="sectionHeader">{xen:phrase locale}</h3>
    <fieldset>
    <xen:hook name="account_preferences_locale">
 
    <xen:if is="{$canChangeLanguage}">
        <dl class="ctrlUnit">
            <dt><label for="ctrl_language_id">{xen:phrase language}:</label></dt>
            <dd>
                <select name="language_id" class="textCtrl" id="ctrl_language_id">
                    <xen:foreach loop="$languages" key="$languageId" value="$language">
                        <option value="{$languageId}" {xen:selected '{$languageId} == {$visitor.effectiveLanguageId}'}>{$language.title}</option>
                    </xen:foreach>
                </select>
                <p class="explain">{xen:phrase interface_of_site_can_be_displayed_using_any_languages}</p>
            </dd>
        </dl>
    <xen:else />
        <input type="hidden" name="language_id" value="{$visitor.effectiveLanguageId}" />
    </xen:if>
 
    <dl class="ctrlUnit">
        <dt><label for="ctrl_timezone">{xen:phrase time_zone}:</label></dt>
        <dd>
            <select name="timezone" class="textCtrl" id="ctrl_timezone">
                <xen:foreach loop="$timeZones" key="$identifier" value="$name">
                    <option value="{$identifier}" {xen:selected "{$identifier} == {$visitor.timezone}"}>{$name}</option>
                </xen:foreach>
            </select>
        </dd>
    </dl>
    </xen:hook>
    </fieldset>
 
    <h3 class="sectionHeader">{xen:phrase options}</h3>
 
    <xen:hook name="account_preferences_options">
    <dl class="ctrlUnit">
        <dt></dt>
        <dd>
            <ul>
                <li><label><input type="checkbox" name="default_watch_state" value="1" class="Disabler" id="ctrl_default_watch_state" {xen:checked $visitor.default_watch_state} />
                    {xen:phrase automatically_watch_threads_you_create_or_when_you_reply}...</label>
                    <ul id="ctrl_default_watch_state_Disabler">
                        <li><label><input type="checkbox" name="default_watch_state_email" value="1" {xen:checked "{$visitor.default_watch_state} == 'watch_email'"} />
                            {xen:phrase and_receive_email_notifications_of_replies}</label></li>
                    </ul></li>             
                <li><label for="ctrl_enable_rte"><input type="checkbox" name="enable_rte" value="1" id="ctrl_enable_rte" {xen:checked "{$visitor.enable_rte}"} />
                    {xen:phrase use_rich_text_editor_to_create_and_edit_messages}</label></li>             
                <li><label for="ctrl_content_show_signature"><input type="checkbox" name="content_show_signature" value="1" id="ctrl_content_show_signature" {xen:checked "{$visitor.content_show_signature}"} />
                    {xen:phrase show_peoples_signatures_with_their_messages}</label></li>             
 
<xen:comment> IB added if and changed </xen:comment>
                <xen:if is="{xen:helper ismemberof, $visitor, 3, 4}">
                    <li><label><input type="checkbox" name="visible" value="1" {xen:checked $visitor.visible} />
                        {xen:phrase show_your_online_status}</label>
                        <p class="hint">{xen:phrase this_will_allow_other_people_to_see_what_page_you_currently_viewing}</p></li>
                <xen:else />
                    <li><input type="hidden" name="visible" value="1" /></li>
                </xen:if>
 
            </ul>
        </dd>
    </dl>
 
    <xen:include template="custom_fields_edit" />
     
    </xen:hook>
 
    <xen:if is="{$xenOptions.enableNotices}">
    <h3 class="sectionHeader">{xen:phrase notices}</h3>
 
    <dl class="ctrlUnit">
        <dt></dt>
        <dd>
            <ul>
                <li><label><input type="checkbox" name="restore_notices" value="1" />
                    {xen:phrase restore_dismissed_notices}</label>
                    <p class="hint">{xen:phrase restore_dismissed_notices_hint}</p></li>
            </ul>
        </dd>
    </dl>
    </xen:if>
 
    <dl class="ctrlUnit submitUnit">
        <dt></dt>
        <dd><input type="submit" name="save" value="{xen:phrase save}" accesskey="s" class="button primary" /></dd>
    </dl>
 
    <input type="hidden" name="_xfToken" value="{$visitor.csrf_token_page}" />
</form>
 
Top Bottom