Page 1 of 1

How to make a required field not required

Posted: Thu Dec 17, 2009 11:41 am
by m4dbra1n
Hi, I need to know how to make a required field not required.

I need this because not all our customers have e-mail, and i want to create ticket even without it.

Thanks in advance ;)

Bye!

Posted: Thu Dec 17, 2009 11:52 am
by Klemen
Change

Code: Select all

$email	  = hesk_validateEmail($_POST['email'],'ERR',0) or $hesk_error_buffer[]=$hesklang['enter_valid_email'];
to

Code: Select all

$email	  = hesk_validateEmail($_POST['email'],'ERR',0);
in submit_ticket.php.

BUT you will also need to configure Hesk not to send e-mails to blank addresses. So, in the same file change

Code: Select all

/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_ticket');
$msg = str_replace('%%NAME%%',hesk_msgToPlain($name,1),$msg);
$msg = str_replace('%%SUBJECT%%',hesk_msgToPlain($subject,1),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',hesk_msgToPlain($message,1),$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($email,$hesklang['ticket_received'],$msg,$headers);
to

Code: Select all

if (!empty($email))
{
/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_ticket');
$msg = str_replace('%%NAME%%',hesk_msgToPlain($name,1),$msg);
$msg = str_replace('%%SUBJECT%%',hesk_msgToPlain($subject,1),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',hesk_msgToPlain($message,1),$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($email,$hesklang['ticket_received'],$msg,$headers);
}


And in admin_reply_ticket.php first change

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email'],"$hesklang[int_error]: No valid orig_email");
to

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email']);
then

Code: Select all

/*** Send "New reply added" e-mail ***/
$message = hesk_msgToPlain($message,1);

/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_reply_by_staff');
$msg = str_replace('%%NAME%%',stripslashes($orig_name),$msg);
$msg = str_replace('%%SUBJECT%%',stripslashes($orig_subject),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',$message,$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($orig_email,$hesklang['new_reply_staff'],$msg,$headers);
to

Code: Select all

if (!empty($orig_email))
{

/*** Send "New reply added" e-mail ***/
$message = hesk_msgToPlain($message,1);

/* Get e-mail message for customer */
$msg = hesk_getEmailMessage('new_reply_by_staff');
$msg = str_replace('%%NAME%%',stripslashes($orig_name),$msg);
$msg = str_replace('%%SUBJECT%%',stripslashes($orig_subject),$msg);
$msg = str_replace('%%TRACK_ID%%',$trackingID,$msg);
$msg = str_replace('%%TRACK_URL%%',$trackingURL,$msg);
$msg = str_replace('%%SITE_TITLE%%',$hesk_settings['site_title'],$msg);
$msg = str_replace('%%SITE_URL%%',$hesk_settings['site_url'],$msg);
$msg = str_replace('%%MESSAGE%%',$message,$msg);

/* Send e-mail */
$headers = "From: $hesk_settings[noreply_mail]\n";
$headers.= "Reply-to: $hesk_settings[noreply_mail]\n";
$headers.= "Return-Path: $hesk_settings[webmaster_mail]\n";
$headers.= "Content-type: text/plain; charset=".$hesklang['ENCODING'];
@mail($orig_email,$hesklang['new_reply_staff'],$msg,$headers);

}

That should about do it :wink:

Posted: Thu Dec 17, 2009 11:57 am
by m4dbra1n
Thanks a lot Klemen :D

I asked that because we are going to use Hesk locally, without send e-mail, for no warranty devices.

Thanks again & keep up with the good work! :)

Posted: Thu Dec 17, 2009 5:47 pm
by m4dbra1n
And if I want to remove it completely, even the form?

Posted: Sat Dec 19, 2009 9:09 am
by Klemen
You could delete the e-mail field from the form (in index.php) and just place a hidden field with the same name and empty value somewhere in the form.

Posted: Thu Dec 24, 2009 2:01 am
by coeugh
Hi, can u please explain exactly what we shud do in order to remove the email from the Submit a ticket ?

Thank you.

Posted: Fri Jan 15, 2010 10:49 am
by m4dbra1n
Ehm... I would like to know it too...

You know, I'm not practice with PHP :(

Posted: Tue Jan 26, 2010 11:55 pm
by country101
The above code seems to work but regarding the

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email'],"$hesklang[int_error]: No valid orig_email");"
By removing the error, I still get a red error box, but now there just isn't anything said in it. So it seems to still try to validate the email when there isn't one present in the ticket.

The "if empty" made sense for me, so I guess not really sure why its not working.

Posted: Wed Jan 27, 2010 12:19 am
by country101
Alright I solved that one. I just couldn't figure it out until I looked at the differences between

Code: Select all

$email     = hesk_validateEmail($_POST['email'],'ERR',0);
and

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email']);
Where I was not getting an error on intial form submission but I would when trying to do a canned reply.

Well I just added

Code: Select all

'ERR',0
to the end of

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email']);
to make it look like

Code: Select all

$orig_email = hesk_validateEmail($_POST['orig_email'],'ERR',0);
and that seemed to solve it.

Re: How to make a required field not required

Posted: Sat Aug 13, 2011 11:29 am
by coeugh
Hi, how can i change this email field to phone field... i want to use this script to support without SMS, i just need to change the email field to Phone Number

so i wuna change the name of this field to phone number and in the same i will need to change the field character in order to make it accept number not only emails form.


Thanks in advance