<?php
add_filter('smart-forms-get-email-fixed-field-listener','smart_forms_email_current_date');
function smart_forms_email_current_date($array)
{
	array_push($array,
		array(
				"Label"=>__("Current Date"),
				"Op"=>"CurrentDate",
				"Parameters"=>array(
					"Format"=>"m/d/y"
				)
			)
	);

	return $array;
}
add_filter('smart-forms-fixed-field-value-CurrentDate','smart_forms_get_fixed_fields_CurrentDate',10,2);
function smart_forms_get_fixed_fields_CurrentDate($fieldParameters,$formData)
{
	return date($fieldParameters["Format"]);
}




add_filter('smart-forms-get-email-fixed-field-listener','smart_forms_email_original_url');
function smart_forms_email_original_url($array)
{
	array_push($array,
		array(
			"Label"=>__("Original URL"),
			"Op"=>"OriginalUrl",
			"Parameters"=>array(
			)
		)
	);

	return $array;
}
add_filter('smart-forms-fixed-field-value-OriginalUrl','smart_forms_get_fixed_fields_OriginalUrl',10,2);
function smart_forms_get_fixed_fields_OriginalUrl($fieldParameters,$formData)
{
	return $_POST['requestUrl'];
}







add_filter('smart-forms-get-email-fixed-field-listener','smart_forms_email_form_id');
function smart_forms_email_form_id($array)
{
    array_push($array,
        array(
            "Label"=>__("Form Id"),
            "Op"=>"FormId",
            "Parameters"=>array(
            )
        )
    );

    return $array;
}
add_filter('smart-forms-fixed-field-value-FormId','smart_forms_get_fixed_fields_FormId',10,2);
function smart_forms_get_fixed_fields_FormId($fieldParameters,$formData)
{
    return $formData['_formid'];
}



add_filter('smart-forms-get-email-fixed-field-listener','smart_forms_email_ip');
function smart_forms_email_ip($array)
{
	array_push($array,
		array(
			"Label"=>__("IP"),
			"Op"=>"IP",
			"Parameters"=>array(
			)
		)
	);

	return $array;
}
add_filter('smart-forms-fixed-field-value-IP','smart_forms_get_fixed_fields_IP',10,2);
function smart_forms_get_fixed_fields_IP($fieldParameters,$formData)
{
	return $_SERVER['REMOTE_ADDR'];
}



add_filter('smart-forms-get-email-fixed-field-listener','smart_forms_logged_user');
function smart_forms_logged_user($array)
{
	array_push($array,
		array(
			"Label"=>__("Username"),
			"Op"=>"USERNAME",
			"Parameters"=>array(
			)
		)
	);

	return $array;
}
add_filter('smart-forms-fixed-field-value-USERNAME','smart_forms_get_fixed_fields_username',10,2);
function smart_forms_get_fixed_fields_username($fieldParameters,$formData)
{
	$current_user = wp_get_current_user();
	if(!$current_user)
		return '';

	return $current_user->user_login;
}
