Hi @violetasites
So this is for the single entry attached to the notification?
If so then u can use something like this. I would add the class to it’s own file, and then include it at the top of your functions.php
.
Then you can use the class like this:
// replace the name of the excel of form 1, with the value of field 1.3
new ReplaceExcelEntryFilename(1, '1.3');
Hope this helps you out. This is the class:
<?php
/**
* Class that renames the excel file for a form to the value of a field.
*/
class ReplaceExcelEntryFilename
{
private $filename;
private $field_id;
private $form_id;
public function __construct($form_id, $field_id)
{
add_filter('gform_notification', [$this, 'retrieveFilename'], 0, 3);
add_filter(sprintf('gfexcel_renderer_filename_%d', $form_id), [$this, 'setFilename']);
$this->field_id = $field_id;
$this->form_id = (int) $form_id;
}
public function retrieveFilename($notification, $form, $entry)
{
if ((int) $form['id'] === $this->form_id) {
$this->filename = $entry[$this->field_id];
}
return $notification;
}
public function setFileName($filename)
{
if ($this->filename) {
$filename = $this->filename;
}
return $filename;
}
}
-
This reply was modified 3 years, 9 months ago by Doeke Norg. Reason: Added code