XF 1.4 Hiding "View your details on your profile page" at account/privacy

imthebest

Well-known member
Hi,

I'm trying to prevent my members from being able to alter the value of "View your details on your profile page" which is set to "All Visitors". I have managed to hide the checkbox with its associated drop-down menu with the following template edition:

In template account_privacy I found:

Code:
                    <li><label for="ctrl_allow_view_profile_enable"><input type="checkbox" name="allow_view_profile_enable" value="1" id="ctrl_allow_view_profile_enable" class="Disabler OptOut" {xen:checked "{$visitor.allow_view_profile} != 'none' "} /> {xen:phrase view_your_details_on_your_profile_page}:</label>
                        <ul id="ctrl_allow_view_profile_enable_Disabler">
                            <li>
                                <select name="allow_view_profile" class="textCtrl autoSize" id="ctrl_allow_view_profile">
                                    <option value="everyone" {xen:selected "{$visitor.allow_view_profile} == 'everyone' "}>{xen:phrase all_visitors}</option>
                                    <option value="members"  {xen:selected "{$visitor.allow_view_profile} == 'members'  "}>{xen:phrase members_only}</option>
                                    <option value="followed" {xen:selected "{$visitor.allow_view_profile} == 'followed' "}>{xen:phrase people_you_follow_only}</option>
                                </select>
                            </li>
                        </ul>
                    </li>

And replaced with:

Code:
<li><input type="hidden" name="allow_view_profile_enable" value="1" id="ctrl_allow_view_profile_enable" class="Disabler OptOut" {xen:checked "{$visitor.allow_view_profile} != 'none' "} />
</li>

However whenever they save the changes at account/privacy the value of "View your details on your profile page" gets changed to "Nobody" despite the checkbox being hidden and its associated drop-down menu not "physically" present on the template anymore.

What could I do to prevent changes on "View your details on your profile page"?

Thanks,
Super120
 
Don't change anything. Simply find:

Code:
<li><label for="ctrl_allow_view_profile_enable"><input type="checkbox" name="allow_view_profile_enable" value="1" id="ctrl_allow_view_profile_enable" class="Disabler OptOut" {xen:checked "{$visitor.allow_view_profile} != 'none' "} /> {xen:phrase view_your_details_on_your_profile_page}:</label>
                        <ul id="ctrl_allow_view_profile_enable_Disabler">
                            <li>
                                <select name="allow_view_profile" class="textCtrl autoSize" id="ctrl_allow_view_profile">
                                    <option value="everyone" {xen:selected "{$visitor.allow_view_profile} == 'everyone' "}>{xen:phrase all_visitors}</option>
                                    <option value="members"  {xen:selected "{$visitor.allow_view_profile} == 'members'  "}>{xen:phrase members_only}</option>
                                    <option value="followed" {xen:selected "{$visitor.allow_view_profile} == 'followed' "}>{xen:phrase people_you_follow_only}</option>
                                </select>
                            </li>
                        </ul>
                    </li>

And comment it out with <xen:comment> before the first <li> and </xen:comment> after the last </li>.
 
Hi Maru, thanks for the tip. Your method is good to hide static elements within a template however you can't use <xen:comment> to hide form elements because those come with default values attached and if you comment the entire block you're going to have the same problem I reported on my original message (values being changed when saving the form even when the elements are not "physically" present on the template anymore).
 
Some forms might give you problems and some others not. Give it a try yourself:

1. On your test installation with a stock account_privacy template go to account/privacy and set the value of "View your details on your profile page" to "All Visitors".
2. Edit the template account_privacy and use your method to get rid of the "View your details on your profile page" block.
3. Now go to account/privacy and save the changes without actually changing anything.
4. Finally login to your ACP, search for your account and see your User Change Log. You will notice that the value of "View your details on your profile page" has been changed to "Nobody".

I suggest you to not hide form elements using <xen:comment>. You can't ignore the values being set in the form elements at the template.
 
Don't remove the whole drop down menu. That's like a waiter asking "Do you want food?", but not giving you any menu. Instead, try this...

Find
Code:
<li>
<label for="ctrl_allow_view_profile_enable"><input type="checkbox" name="allow_view_profile_enable" value="1" id="ctrl_allow_view_profile_enable" class="Disabler OptOut" {xen:checked "{$visitor.allow_view_profile} != 'none' "} /> {xen:phrase view_your_details_on_your_profile_page}:</label>
             <ul id="ctrl_allow_view_profile_enable_Disabler">
               <li>
                 <select name="allow_view_profile" class="textCtrl autoSize" id="ctrl_allow_view_profile">
                   <option value="everyone" {xen:selected "{$visitor.allow_view_profile} == 'everyone' "}>{xen:phrase all_visitors}</option>
                   <option value="members"  {xen:selected "{$visitor.allow_view_profile} == 'members'  "}>{xen:phrase members_only}</option>
                   <option value="followed" {xen:selected "{$visitor.allow_view_profile} == 'followed' "}>{xen:phrase people_you_follow_only}</option>
                 </select>
               </li>
             </ul>
           </li>

Replace

Code:
<div style="visibility:hidden;">
<li><label for="ctrl_allow_view_profile_enable"><input type="checkbox" name="allow_view_profile_enable" value="1" id="ctrl_allow_view_profile_enable" class="Disabler OptOut" checked  /> {xen:phrase view_your_details_on_your_profile_page}:</label>
             <ul id="ctrl_allow_view_profile_enable_Disabler">
               <li>
                 <select name="allow_view_profile" class="textCtrl autoSize" id="ctrl_allow_view_profile">
                   <option value="everyone" {xen:selected "{$visitor.allow_view_profile} == 'everyone' "}>{xen:phrase all_visitors}</option>
                 </select>
               </li>
             </ul>
           </li>
</div>

See if that works. I use the same method in account_privacy_dob without any issue
 
Back
Top Bottom