Font end entry
-
Hello,
When i use gravity form default upload i use to print picture in front end
$value = rgar( $entry, ’36’);
$files = json_decode( $value, true );
rgar( $files,0)But when i use this with your plugin nothing^^
How can i do ?
Regards
https://www.ads-software.com/plugins/gravity-forms-advanced-file-uploader/
-
Hi
Are you creating a post with the form submission?
If you are creating a post with the submission, any files are attached to that post and you can grab them from the post using the post id.
no it’s not for a post it’s for custom
my form :
https://www.inrunews.com/en/add-obituary-notice/where it’s display
https://www.inrunews.com/en/obituary-notice/ok, how is this page generated?:
https://www.inrunews.com/en/obituary-notice/
Is it looping through all the entries for the form?
yes
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );Hi
I had to make a change to support this so you will have to download v1.27
1. Get entries as normal :
$entries = GFAPI::get_entries( $form_id )
2. Each entry will now have a serialized array of file id’s where the uploader field data is:
e.g. If the uploader is field number 8, the file array would be at:
$entries[0][8]
3. you can access the array of file id’s using something like this:
maybe_unserialize( $entries[0][8] );
Once you have the file ids you just loop through then and use this wordpress function to get the file url:
wp_get_attachment_url( $file_id );
Now you have the full url to each uploaded file!
I update the plugin
i did :
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );
foreach($entries as $entry) {
$file_id = maybe_unserialize( $entries[0][36]);
<img class=”avisImages” src=”‘.wp_get_attachment_url( $file_id).'” />
}don’t work ??
maybe i don’t understand something
Sorry ??
$form_id, $search_criteria, $sorting, $paging, $total_count
These are all variables, are you providing these vars to the get_entries method?
get_entries requires the id of the form you wish to get entries for.
Can you provide the entire code you are using.
function calculateAge($dob, $date=null) {
$dob = strtotime($dob);
$date = $date ? strtotime($date) : time();
// Calculate the age
$age = date(‘Y’, $date)-date(‘Y’, $dob);// Correct age for leap year
return (date(‘md’, date(‘U’, $dob)) > date(‘md’, date(‘U’, $date)))
? $age-1 : $age;}
//Choix du formulaire
$form_id = 1;$search_criteria = array(
‘status’ => ‘active’,
‘field_filters’ => array(
‘mode’ => ‘any’,
array(
‘key’ => ‘payment_status’,
‘value’ => ‘Paid’
),
array(
‘key’ => ’22’,
‘operator’ => ‘<=’,
‘value’ => ‘NOW()’
),
array(
‘key’ => ’21’,
‘operator’ => ‘>=’,
‘value’ => ‘NOW()’
)
)
);$my_param = $_GET[‘urlparams’];
$perPage = 10;
$total_count= GFAPI::count_entries( $form_id, $search_criteria );// Nombre total de page
$nbPage = ceil($total_count/$perPage);if (isset($my_param) && $my_param>0 && $my_param <=$nbPage) {
$sPage = $my_param ;
}
else{
$sPage = 1;
}$sorting = array( ‘key’ => ‘date_created’, ‘direction’ => ‘DESC’ );
$paging = array( ‘offset’ => (($sPage-1)*$perPage) , ‘page_size’ => $perPage );
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );
echo ‘<table style=”width: 100%; background-color: #2e2e2e;”><tbody>’;
foreach($entries as $entry) {
echo ‘<tr>’;
echo ‘<td colspan=”4″><span style=”color: #ffffff;”>’ . rgar( $entry,’6.3′) . ‘ ‘ . rgar( $entry,’6.6′) .’ (Age:’.calculateAge(rgar( $entry,’4′),rgar( $entry,’12’)).’)</span></td>’;
echo ‘</tr><tr>’;$file_id = maybe_unserialize( $entries[0][36]);
echo ‘<td style=”width: 150px; text-align: center; vertical-align: middle;” rowspan=”3″><img class=”avisImages” src=”‘.wp_get_attachment_url( $file_id).'” /></td>’;
echo ‘<td style=”width: 30%; text-align: right; background-color: #a6a6a6;”>?Place of Birth:</td>’ ;
echo ‘<td style=”width: 50%; background-color: #a6a6a6;” colspan=”2″>’ . rgar( $entry,’11’) . ‘ </td>’;
echo ‘</tr><tr>’;
echo ‘<td style=”width: 30%; text-align: right; background-color: #a6a6a6;”>?Place of Death:</td>’;
echo ‘<td style=”width: 50%; background-color: #a6a6a6;” colspan=”2″> ‘ . rgar( $entry,’13’) . ‘ ?</td>’;
echo ‘</tr><tr>’;
echo ‘<td style=”width: 30%; text-align: right; background-color: #a6a6a6;”>?Date of death:</td>’;
echo ‘<td style=”width: 50%; background-color: #a6a6a6;” colspan=”2″>’ . rgar( $entry,’12’) . ‘ ?</td></tr>’;
echo ‘<tr><td style=”height:2px; background-color:#ffffff;”><td colspan=”2″ style=”height:5px; background-color:#ffffff;”></td></tr>’;
}echo ‘</tbody></table>’;
if(!empty($my_param) AND intval($my_param)>0 AND intval($my_param)<=$nbPage ){$page=$my_param;}else{$sPage=1;}
if($sPage>1){
// echo “Première page “;
$precedent=$sPage-1;
echo “ << “;
}if($sPage<$nbPage){
$suivant=$sPage+1;
echo “ >> “;
// echo “Dernière page “;
}Yeah, that will not work at all.
You can try this, it should echo out the url to each file uploaded in the entry:
function calculateAge($dob, $date=null) {
$dob = strtotime($dob);
$date = $date ? strtotime($date) : time();
// Calculate the age
$age = date(‘Y’, $date)-date(‘Y’, $dob);
// Correct age for leap year
return (date(‘md’, date(‘U’, $dob)) > date(‘md’, date(‘U’, $date)))
? $age-1 : $age;
}
//Choix du formulaire
$form_id = 1;
$search_criteria = array(
‘status’ => ‘active’,
‘field_filters’ => array(
‘mode’ => ‘any’,
array(
‘key’ => ‘payment_status’,
‘value’ => ‘Paid’
),
array(
‘key’ => ’22’,
‘operator’ => ‘=’,
‘value’ => ‘NOW()’
)
)
);$my_param = $_GET[‘urlparams’];
$perPage = 10;
$total_count= GFAPI::count_entries( $form_id, $search_criteria );// Nombre total de page
$nbPage = ceil($total_count/$perPage);
if (isset($my_param) && $my_param>0 && $my_param ‘date_created’, ‘direction’ => ‘DESC’ );
$paging = array( ‘offset’ => (($sPage-1)*$perPage) , ‘page_size’ => $perPage );
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );
echo ”;
foreach($entries as $entry) {
echo ”;
echo ” . rgar( $entry,’6.3′) . ‘ ‘ . rgar( $entry,’6.6′) .’ (Age:’.calculateAge(rgar( $entry,’4′),rgar( $entry,’12’)).’)’;
echo ”;//Echo out file urls
get_entry_files( $entry );echo ”;
echo ‘ Place of Birth:’ ;
echo ” . rgar( $entry,’11’) . ‘ ‘;
echo ”;
echo ‘ Place of Death:’;
echo ‘ ‘ . rgar( $entry,’13’) . ‘ ‘;
echo ”;
echo ‘ Date of death:’;
echo ” . rgar( $entry,’12’) . ‘ ‘;
echo ”;
}echo ”;
if(!empty($my_param) AND intval($my_param)>0 AND intval($my_param)1){
// echo “Première page “;
$precedent=$sPage-1;
echo ” > “;
// echo “Dernière page “;
}function get_entry_files( $entry ) {
//Vars
$uploader_field_number = 36;
$file_array = array();
$file_urls = array();//Check for uploader field
if( isset($entry[ $uploader_field_number ]) && is_array($entry[ $uploader_field_number ]) ) {$file_array = $entry[ $uploader_field_number ];
//Loop file array and cache url for each file
foreach( $file_array as $file_id ) {$file_urls[] = wp_get_attachment_url( $file_id );
}
}
//output urls
foreach( $file_urls as $url ) {echo $url;
}
}
don’t work ??
Can you replace this function and let me know the output:
function get_entry_files( $entry ) {
var_dump($entry);
exit();//Vars
$uploader_field_number = 36;
$file_array = array();
$file_urls = array();//Check for uploader field
if( isset($entry[ $uploader_field_number ]) && is_array($entry[ $uploader_field_number ]) ) {$file_array = $entry[ $uploader_field_number ];
//Loop file array and cache url for each file
foreach( $file_array as $file_id ) {$file_urls[] = wp_get_attachment_url( $file_id );
}
}
//output urls
foreach( $file_urls as $url ) {echo $url;
}
}
array(47) { [“id”]=> string(2) “14” [“form_id”]=> string(1) “1” [“date_created”]=> string(19) “2015-08-28 19:47:30” [“is_starred”]=> int(0) [“is_read”]=> int(1) [“ip”]=> string(12) “90.15.234.72” [“source_url”]=> string(47) “https://www.inrunews.com/en/add-obituary-notice/” [“post_id”]=> NULL [“currency”]=> string(3) “CHF” [“payment_status”]=> string(4) “Paid” [“payment_date”]=> string(19) “2015-08-28 19:47:51” [“transaction_id”]=> string(17) “28H01656FU8655025” [“payment_amount”]=> string(5) “65.00” [“payment_method”]=> string(6) “PayPal” [“is_fulfilled”]=> string(1) “1” [“created_by”]=> string(1) “1” [“transaction_type”]=> string(1) “1” [“user_agent”]=> string(110) “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36” [“status”]=> string(6) “active” [4]=> string(10) “2000-08-03” [“6.3”]=> string(7) “Camelle” [“6.6”]=> string(5) “Brian” [11]=> string(5) “Paris” [12]=> string(10) “2015-08-28” [13]=> string(5) “Paris” [17]=> string(2) “65” [“18.1”]=> string(36) “Publish Obituary notice CHF 1 / day” [“18.2”]=> string(8) “CHF 1.00” [21]=> string(10) “2015-08-27” [22]=> string(10) “2015-08-27” [23]=> string(2) “65” [24]=> string(150) “a:1:{i:0;a:5:{s:4:”Name”;s:6:”yanick”;s:4:”Link”;s:4:”fils”;s:8:”Location”;s:5:”Paris”;s:5:”Phone”;s:9:”063265987″;s:5:”Email”;s:13:”[email protected]”;}}” [25]=> string(116) “a:1:{i:0;a:3:{s:4:”Type”;s:11:”Cérémonie”;s:14:”Date and hours”;s:15:”21 oct 18 h 21h”;s:6:”Adress”;s:5:”paris”;}}” [26]=> string(60) “
bonjourvoici le texte
merci
” [“6.2”]=> string(0) “” [“6.4”]=> string(0) “” [“6.8”]=> string(0) “” [35]=> string(0) “” [36]=> string(0) “” [29]=> string(0) “” [30]=> string(0) “” [33]=> string(0) “” [34]=> string(0) “” [“18.3”]=> string(0) “” [31]=> string(0) “” [32]=> string(0) “” [28]=> string(0) “” }
There is no file data in that example entry you posted.
Try replacing this and send the output again, I need to see all the entries:
function calculateAge($dob, $date=null) {
$dob = strtotime($dob);
$date = $date ? strtotime($date) : time();
// Calculate the age
$age = date(‘Y’, $date)-date(‘Y’, $dob);
// Correct age for leap year
return (date(‘md’, date(‘U’, $dob)) > date(‘md’, date(‘U’, $date)))
? $age-1 : $age;
}
//Choix du formulaire
$form_id = 1;
$search_criteria = array(
‘status’ => ‘active’,
‘field_filters’ => array(
‘mode’ => ‘any’,
array(
‘key’ => ‘payment_status’,
‘value’ => ‘Paid’
),
array(
‘key’ => ’22’,
‘operator’ => ‘=’,
‘value’ => ‘NOW()’
)
)
);$my_param = $_GET[‘urlparams’];
$perPage = 10;
$total_count= GFAPI::count_entries( $form_id, $search_criteria );// Nombre total de page
$nbPage = ceil($total_count/$perPage);
if (isset($my_param) && $my_param>0 && $my_param ‘date_created’, ‘direction’ => ‘DESC’ );
$paging = array( ‘offset’ => (($sPage-1)*$perPage) , ‘page_size’ => $perPage );
$entries = GFAPI::get_entries( $form_id, $search_criteria, $sorting, $paging, $total_count );
echo ”;
foreach($entries as $entry) {
echo ”;
echo ” . rgar( $entry,’6.3′) . ‘ ‘ . rgar( $entry,’6.6′) .’ (Age:’.calculateAge(rgar( $entry,’4′),rgar( $entry,’12’)).’)’;
echo ”;//Echo out file urls
get_entry_files( $entries );echo ”;
echo ‘ Place of Birth:’ ;
echo ” . rgar( $entry,’11’) . ‘ ‘;
echo ”;
echo ‘ Place of Death:’;
echo ‘ ‘ . rgar( $entry,’13’) . ‘ ‘;
echo ”;
echo ‘ Date of death:’;
echo ” . rgar( $entry,’12’) . ‘ ‘;
echo ”;
}echo ”;
if(!empty($my_param) AND intval($my_param)>0 AND intval($my_param)1){
// echo “Première page “;
$precedent=$sPage-1;
echo ” > “;
// echo “Dernière page “;
}function get_entry_files( $entry ) {
var_dump($entry);
exit();//Vars
$uploader_field_number = 36;
$file_array = array();
$file_urls = array();//Check for uploader field
if( isset($entry[ $uploader_field_number ]) && is_array($entry[ $uploader_field_number ]) ) {$file_array = $entry[ $uploader_field_number ];
//Loop file array and cache url for each file
foreach( $file_array as $file_id ) {$file_urls[] = wp_get_attachment_url( $file_id );
}
}
//output urls
foreach( $file_urls as $url ) {echo $url;
}
}
test
View File #1 (.jpg), View File #2 (.jpg), View File #3 (.jpg), View File #4 (.jpg),they are pictures
array(47) { [“id”]=> string(2) “15” [“form_id”]=> string(1) “1” [“date_created”]=> string(19) “2015-08-28 21:22:21” [“is_starred”]=> int(0) [“is_read”]=> int(0) [“ip”]=> string(12) “90.15.234.72” [“source_url”]=> string(47) “https://www.inrunews.com/en/add-obituary-notice/” [“post_id”]=> NULL [“currency”]=> string(3) “CHF” [“payment_status”]=> string(4) “Paid” [“payment_date”]=> string(19) “2015-08-28 21:22:40” [“transaction_id”]=> string(17) “36T17855A99669710” [“payment_amount”]=> string(4) “1.00” [“payment_method”]=> string(6) “PayPal” [“is_fulfilled”]=> string(1) “1” [“created_by”]=> string(1) “1” [“transaction_type”]=> string(1) “1” [“user_agent”]=> string(110) “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.157 Safari/537.36” [“status”]=> string(6) “active” [4]=> string(10) “2015-08-12” [“6.3”]=> string(4) “test” [“6.6”]=> string(4) “test” [11]=> string(5) “paris” [12]=> string(10) “2015-08-10” [13]=> string(5) “paris” [17]=> string(1) “1” [“18.1”]=> string(36) “Publish Obituary notice CHF 1 / day” [“18.2”]=> string(8) “CHF 1.00” [21]=> string(10) “2015-08-28” [22]=> string(10) “2015-08-28” [23]=> string(1) “1” [36]=> string(50) “a:4:{i:0;i:6181;i:1;i:6182;i:2;i:6183;i:3;i:6184;}” [“6.2”]=> string(0) “” [“6.4”]=> string(0) “” [“6.8”]=> string(0) “” [35]=> string(0) “” [29]=> string(0) “” [30]=> string(0) “” [33]=> string(0) “” [25]=> string(0) “” [24]=> string(0) “” [26]=> string(0) “” [34]=> string(0) “” [“18.3”]=> string(0) “” [31]=> string(0) “” [32]=> string(0) “” [28]=> string(0) “” }
test test (Age:-1)did you replace all the code i provided last?
This should be an array of ALL entries not just a single entry
- The topic ‘Font end entry’ is closed to new replies.