为了在表单所在的页面上执行此操作,最好知道该页面的ID。我们假设您有这些信息,并且只想将这些信息嵌入到此页面中。所以在你的gform_after_submission
胡克,你会想要这样的东西:
$id_of_page = 36; // change this
// false means we want all values as array, not single
$array_of_submitters = get_post_meta($id_of_page, \'my_custom_field\', false);
if(empty($array_of_submitters)){
// has not yet been made, setup variable
$array_of_submitters = array();
}
// add new value to array
$array_of_submitters[] = $entry[12]; // whatever field you need
// update!
update_post_meta($id_of_page, \'my_custom_field\', $array_of_submitters);
然后在您的页面中,您只需像这样重复这些内容:
$array_of_submitters = get_post_meta($post->ID, \'my_custom_field\', false);
// make sure it has values first so we don\'t look foolish
if(!empty($array_of_submitters)){
echo \'<h4>People who did something</h4>\';
echo \'<ul>\';
// echo each value out as list
foreach($array_of_submitters as $submitter){
echo \'<li>\'.$submitter.\'</li>\';
}
echo \'</ul>\';
}