• I am trying to create a php filter in a child theme’s functions.php to add the time, day of week etc in a gravity forms notifications structure.
    I have managed to change the correct code in gravity’s common.php to achieve this but when a new gravity update comes along this could be wiped out. In gravity the following is placed in the message box of notifications:-

    {all_fields:admin,value,empty}
    Entry ID: {entry_id}
    Date of Post: {date_dmy}
    User Agent:{user_agent}

    The change I made in the common.php is as follows:-

    public static function replace_variables_prepopulate($text, $url_encode=false) {
    
    //date (mm/dd/yyyy) original code
            $local_date_mdy = date_i18n("m/d/Y", $local_timestamp, true);
            $text = str_replace("{date_mdy}", $url_encode ? urlencode($local_date_mdy) : $local_date_mdy, $text);
    
            //date (dd/mm/yyyy)
    
    	//$local_date_dmy = date_i18n("d/m/Y", $local_timestamp, true); -- replaced this line with:-
    
    	$local_date_dmy = date_i18n("d/m/Y  (g:i:s a) l (e)", $local_timestamp, true);
    
            $text = str_replace("{date_dmy}", $url_encode ? urlencode($local_date_dmy) : $local_date_dmy, $text);

    Product of above code on a notification email
    Entry ID: 84
    Date of Post: 08/04/2014 (5:18:23 pm) Tuesday (Australia/Adelaide)
    User Agent: Mozilla/5.0 (Windows NT 5.1; rv:28.0) Gecko/20100101 Firefox/28.

    Cheers Eric

  • The topic ‘Gravity forms – need to modify common.php code’ is closed to new replies.