我第一次进入stackoverflow,你好吗?
我有一个插件,该插件具有一个表单,可以从admin部分将表单插入其数据库。 我想将此表格发送给我网站上的所有注册用户。
我想知道你是否可以帮助我。
我当时正在考虑使用快捷方式
谢谢
这是管理功能:
function add()
{
global $wpdb,$wpfh_plugins;
add_action('admin_init', 'editor_admin_init');
add_action('admin_head', 'editor_admin_head');
if($_POST['save-obit'] != ""){
$insert['id'] = $_POST['id'];
$insert['approved'] = $_POST['approved'];
$insert['first_name'] = $_POST['first_name'];
$insert['maiden'] = $_POST['maiden'];
$insert['middle'] = $_POST['middle'];
$insert['last_name'] = $_POST['last_name'];
$insert['burial_date'] = $_POST['burial_date'];
$insert['birth_date'] = $_POST['birth_date'];
$insert['death_date'] = $_POST['death_date'];
$insert['obituary'] = $_POST['obituary'];
$insert['obit_notes'] = $_POST['obit_notes'];
$insert['vet'] = $_POST['vet'];
//$insert['visitation_time'] = $_POST['visitation_time'];//
$insert['visitation_time']="11";
//$insert['service_time'] = $_POST['service_time'];
$insert['service_time']="11";
if($_FILES['photo']['name'] != ""){
$photo = wp_upload_bits($_FILES['photo']["name"], null, file_get_contents($_FILES['photo']["tmp_name"]));
$insert['photo'] = $photo['url'];
}
if($_POST['id'] == ""){
$insert['created'] = date("Y-m-d H:i:s",current_time( 'timestamp' ));
$wpdb->insert("".$wpdb->prefix ."wpfh_obits", $insert);
$insert_id = $wpdb->insert_id;
do_action('wpfh_insert_obit',$insert_id);
if(class_exists('wpfh_cem_admin')){global $wpfh_cem_admin; $wpfh_cem_admin->obit_save($wpdb->insert_id); }
}else{
$where['id'] = $_POST['id'];
$wpdb->update("".$wpdb->prefix ."wpfh_obits", $insert,$where);
$insert_id = $where['id'];
do_action('wpfh_update_obit',$insert_id);
if(class_exists('wpfh_cem_admin')){global $wpfh_cem_admin; $wpfh_cem_admin->obit_save($_POST['id']); }
}
wpfh_redirect('admin.php?page=wpfh&function=edit&id='.$insert_id.'&saved=1');
}
if($_GET['id'] != ""){
$r = $wpdb->get_results("SELECT * FROM ".$wpdb->prefix ."wpfh_obits where id = ".$wpdb->escape($_GET['id'])."", ARRAY_A);
$extra = '<input name="id" type="hidden" value="'.$r[0]['id'].'"/>';
if($r[0]['vet'] == 0){
$vet = ''.__("No","sp-wpfh").'';
}else{
$vet = ''.__("Yes","sp-wpfh").'';
}
}
$vtype = $_GET['vtype'];
if($vtype == ''){
$vobit = 'id="current"';
}
if($vtype == 'qrcode'){
$vq = 'id="current"';
}
if($vtype == 'guestbook'){
$vg = 'id="current"';
}
echo '<div id="wpfh-header">
<ul>
<li '.$vobit.'><a href="admin.php?page=wpfh&function=edit&id='.$_GET['id'].'" >'.__("Obit","sp-wpfh").'</a></li>
<li '.$vg .'><a href="admin.php?page=wpfh&function=edit&id='.$_GET['id'].'&vtype=guestbook">'.__("Guestbook","sp-wpfh").'</a></li>';
if(class_exists('wpfh_cem_admin')){
echo '<li '.$vq.'><a href="admin.php?page=wpfh&function=edit&id='.$_GET['id'].'&vtype=qrcode">'.__("QR Code","sp-wpfh").'</a></li>';
}
do_action('admin_obit_editor');
echo '<li '.$vg .'><a href="'.wpfh_obit_page($_GET['id']).'">'.__("View Obit","sp-wpfh").'</a></li></ul>
<div style="clear:both"></div>
</div>';
switch($vtype){
default:
if($_GET['vtype'] != ''){
do_action('admin_edit_vtype',$r);
}else{
if($r[0]['approved'] == 1){ $pub = ' selected="selected" '; }else{ $pub2 = ' selected="selected" '; }
if($_GET['saved'] == 1){
echo '<div class="wpfh_success">Obituary Updated</div>';
}
if($r[0]['approved'] == ''){ $pub = ' selected="selected" '; $pub2 = ' ';}
echo '
<div id="wpfh_obit">
<form method="post" action="admin.php?page=wpfh&function=add" enctype="multipart/form-data">
'. $extra.'
<table class="wp-list-table widefat fixed posts" cellspacing="0">';
do_action('wpfh_admin_obit_additional_fields_top',$r);
echo '
<tr>
<td width="148"><label for="first_name">'.__("Published","sp-wpfh").'</label></td>
<td><select name="approved"> <option value="1" '.$pub .'>Yes</option><option value="0" '.$pub2 .'>No</option></select></td>
</tr>
<tr>
<td width="148"><label for="first_name">'.__("First Name","sp-wpfh").'</label></td>
<td><input id="first_name" name="first_name" value="'.stripslashes($r[0]['first_name']).'" title="First name of deceased"/></td>
</tr>
<tr>
<td><label for="middle">'.__("Middle Initial","sp-wpfh").'</label></td>
<td><input id="middle" name="middle" value="'.stripslashes($r[0]['middle']).'"/></td>
</tr>
<tr>
<td><label for="last_name">'.__("Last Name","sp-wpfh").'</label></td>
<td><input id="last_name" name="last_name" value="'.stripslashes($r[0]['last_name']).'"/></td>
</tr>
<tr>
<td><label for="maiden">'.__("Maiden Name","sp-wpfh").'</label></td>
<td><input id="maiden" name="maiden" value="'.stripslashes($r[0]['maiden']).'"/></td>
</tr>
<tr>
<td> <label for="birth_date">'.__("Birth Date","sp-wpfh").'</label></td>
<td><input id="birth_date" name="birth_date" value="'.stripslashes($r[0]['birth_date']).'" class="datepicker"/></td>
</tr>
<tr>
<td><label for="death_date">'.__("Death Date","sp-wpfh").'</label></td>
<td><input id="death_date" name="death_date" value="'.stripslashes($r[0]['death_date']).'" class="datepicker"/></td>
</tr>
<tr>
<td><label for="burial_date">'.__("Funeral Services Date","sp-wpfh").'</label></td>
<td><input id="burial_date" name="burial_date" value="'.stripslashes($r[0]['burial_date']).'" class="datepicker"/></td>
</tr>';
echo '<tr>
<td><label for="funeral_times">'.__("Visitation Notes","sp-wpfh").': </label></td>
<td><input id="maiden" name="obit_notes" value="'.stripslashes($r[0]['obit_notes']).'" style="width:300px"/></td>
</tr>';
echo '<tr>
<td><label for="vet">'.__("Is a US Veteran?","sp-wpfh").'</label></td>
<td><select name="vet">
<option value="'.$r[0]['vet'].'">'.$vet .'</option>
<option value="0" >'.__("No","sp-wpfh").'</option>
<option value="1" >'.__("Yes","sp-wpfh").'</option>
</select></td>
</tr>
';
if(class_exists('wpfh_cem_admin')){global $wpfh_cem_admin; echo $wpfh_cem_admin->obit_form($_GET['id']); }
echo '
<tr>
<td >
<label for="obituary">'.get_option('wpfh_obit_name').'</label></td><td>
</label>';
$r='';
echo wp_editor(stripslashes($r[0]['obituary']), "obituary", "", true);
echo '
</td>
</tr>
';
if($r[0]['photo'] != ""){
echo '<tr>
<td>'.__("Current Photo","sp-wpfh").'</td>
<td >
<div style="border:1px solid #CCC;padding:5px">
<p id="thephoto"><img height="150" src="'.stripslashes($r[0]['photo']).'"/>
<br />
</p>
<p>'.__("New Photo","sp-wpfh").': <input id="photo" name="photo" type="file"></td>
</tr>';
}else{
echo '<tr>
<td><label for="photo">'.__("Photo","sp-wpfh").'</label></td>
<td><input id="photo" name="photo" type="file"/></td>
</tr>';
}
do_action('wpfh_admin_obit_additional_fields_bottom',$r);
echo '
<tr><td></td><td><input type="submit" value="Save" name="save-obit"/></td></tr>
</table>
</form></div>';
}
break;
case"guestbook":
echo '<div id="wpfh_guestbook">';
$this->guestbook($_GET['id']);
echo '</div>';
break;
case"qrcode":
if(class_exists('wpfh_cem_admin')){global $wpfh_cem_admin; echo $wpfh_cem_admin->qr_code(); }
break;
}
}