Jump to content

hide some domain contact fields at client area ?


rugg

Recommended Posts

13 hours ago, rugg said:

i'm sorry, is it possible you give me some sample about it?

because i check the document, i still do not understand how to code it.

the problem with this hook is that you're not querying the database, but the domain contact information is being pulled from the Registrar directly... and each registrar uses many different fields, and some have multiple contacts (admin, technical etc), so without knowing which registrar and fields you want to hide, it's difficult to code an example hook that you could modify... and if you're using multiple registrars, then the code could be even more complicated.

one quick alternative method would be to edit the clientareadomaincontactinfo.tpl template and change...

                {foreach key=name item=value from=$values}
                    <div class="form-group">
                        <label>{$name}</label>
                        <input type="text" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" />
                    </div>
                {/foreach}

to...

                {foreach key=name item=value from=$values}
                    <div class="form-group">
                        <label>{$name}</label>
                        <input type="text" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" {if $name eq "Country"} readonly{/if}/>
                    </div>
                {/foreach}

this would make the "Country" form field read-only and the client cannot edit it.

5RBVAf6.png

if you want to disable multiple form fields, you can use a list...

<input type="text" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" {if $name|in_array:['Phone Number','Country']} readonly{/if}/>

the above would disable both Phone Number and Country from being edited by the client.

Link to comment
Share on other sites

4 hours ago, rugg said:

thanks for it,your codes are used for readonly,and i hope hide it.

the reason why I made them readonly was to ensure that all the domain contact information was still sent to the registrar as it expected... once you start removing/hiding fields, then there is the potential to cause issues, e.g if you were to remove a registrar required field.

but let me show you two quick ways... first by removing them entirely from the page, and then hiding them...

                {foreach key=name item=value from=$values}
		{if !$name|in_array:['Phone Number','Country']}
                    <div class="form-group">
                        <label>{$name}</label>
                        <input type="text" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" />
                    </div>
		{/if}
                {/foreach}

so the above code will totally remove the "Phone Number" and "Country" fields from the form...

if you want to just hide them, then the code gets more involved...

                {foreach key=name item=value from=$values}
                    <div class="form-group">
                        {if !$name|in_array:['Phone','Country']}<label>{$name}</label>{/if}
                        <input type="{if $name|in_array:['Phone','Country']}hidden{else}text{/if}" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" />
                    </div>
                {/foreach}

again, this removes those two fields from the output, but they are still there as hidden fields.

untested with real domain contact info data, but it should work. :idea:

Link to comment
Share on other sites

Hi,brian!

thanks for your reply,i follow your first part and add the following part,i replace Phone Number  and Country as other field names,

but the domain contact parts are all gone.

{if !$name|in_array:['Phone Number','Country']}

 

is it possible i make some mistake ?

 

thanks

Link to comment
Share on other sites

Hi,brian!

i modify the file clientareadomaincontactinfo.tpl as the following,

is it correct ?

 

 

thanks lot.

 

 

<h3>{$LANG.domaincontactinfo}</h3>

{include file="$template/includes/alert.tpl" type="info" msg=$LANG.whoisContactWarning}

{if $successful}
    {include file="$template/includes/alert.tpl" type="success" msg=$LANG.changessavedsuccessfully textcenter=true}
{/if}

{if $error}
    {include file="$template/includes/alert.tpl" type="error" msg=$error textcenter=true}
{/if}

<form method="post" action="{$smarty.server.PHP_SELF}?action=domaincontacts">

    <input type="hidden" name="sub" value="save" />
    <input type="hidden" name="domainid" value="{$domainid}" />

    <div class="row">

        {foreach from=$contactdetails name=contactdetails key=contactdetail item=values}

            <div class="col-md-6">

                <h4>{$contactdetail} {$LANG.supportticketscontact}</h4>
                {foreach key=name item=value from=$values}
				{if !$name|in_array:['Phone Number','Country']}
                    <div class="form-group">
                        <label>{$name}</label>
                        <input type="text" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" />
                    </div>
                {/foreach}

            </div>

        {/foreach}

    </div>

    <br />

    <p class="text-center">
        <input type="submit" value="{$LANG.clientareasavechanges}" class="btn btn-primary" />
        <input type="reset" value="{$LANG.clientareacancel}" class="btn btn-default" />
    </p>

</form>

 

Link to comment
Share on other sites

you've missed out a closing {/if} from the foreach loop...

                {foreach key=name item=value from=$values}
		{if !$name|in_array:['Phone Number','Country']}
                    <div class="form-group">
                        <label>{$name}</label>
                        <input type="text" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" />
                    </div>
		{/if}
                {/foreach}

 

Link to comment
Share on other sites

as @brian! mentioned, removing one or more fields entirely may/will cause errors if you submit these the form missing the required fields, if you need to hide it completely use a simple CSS class as follow:

{foreach key=name item=value from=$values}
		
                    <div class="form-group{if $name|in_array:['Phone Number','Country']} hidden{/if}">
                        <label>{$name}</label>
                        <input type="text" name="contactdetails[{$contactdetail}][{$name}]" value="{$value}" class="form-control {$contactdetail}customwhois" />
                    </div>
                {/foreach}

this will hide the specified fields completely while they remain exists so no errors should occur from it

Link to comment
Share on other sites

14 hours ago, rugg said:

it seems when i have different language,

i need add each language's field name ?

which registrar are you using ?? when I tried it with Nominet or OpenSRS, the form fields always use English, no matter what the language setting in WHMCS is. :?:

it might also be helpful to post screenshots of the field names in multiple languages - if they're using language strings accessible by WHMCS, it should be a simple fix... otherwise, you may well need to add the field name in each available language.

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use & Guidelines and understand your posts will initially be pre-moderated