Jump to content

hide custom fields if domain transfer


wtricks

Recommended Posts

I have a cms hosting product. I'm asking my customers (using custom fields) to fill some data (script, username, password, language)

of course this is pointless if they are transferring their domain, as there is no need to install the script (and ask for those data) if the client will need to transfer the website.

 

I have this code:

add_hook('ClientAreaPageCart', 1, function($vars) {

	$pids = Array(17085, 17087);
    	
    	if( !empty($vars['customfields']) ) {
			$key = array_search($vars['domain'], array_column($_SESSION['domain_cart']['domains'], 'domain'));
			$key2 = array_search($vars['domain'], array_column($_SESSION['domain_cart']['products'], 'domain'));
			$type = $_SESSION['domain_cart']['domains'][$key]['type'];
			if ( $type == 'transfer' && in_array($vars['productinfo']['pid'], $pids) ) {
				foreach ( $vars['customfields'] as $key => $value ) {
					unset($vars['customfields'][$key]);
				}
			}
    	}
    	return $vars;
    
});

it actually works well but has a problem, since the fields are required, you get an error as they are required. At least I got half the job done, I made them disappear ;)

I tried this:

$vars['customfields'][$key]['required'] = '';

with no success.

also set the fileds as not required and then if the domain is not transfer set this:

$vars['customfields'][$key]['required'] = '*';

bus seems like the validation is ignoring my hook

 

what can you recommend to hide custom fields if the domain is a transfer?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • 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