我想添加用户将图像附加到他们提交给wordpress帖子的表单的功能。任何人都这样做或知道如何?
class submit_custom_forms{
public function __construct() {
}
public function processForms(){
extract($_POST);
$postData = array(
'post_title' => wp_strip_all_tags( $full_name ),
'post_status' => 'pending',
'post_type' => 'story', /*the custom post type*/
'post_author' => 1,
'post_category' => array($catID));
$pid = wp_insert_post( $postData );
//Process Custom Fields
if(!empty($pid) && is_numeric($pid) && !empty($custom)){
foreach($custom as $key => $value){
if(!empty($value) && !is_array($value)){
add_post_meta($pid, $key, $value);
} elseif(!empty($value) && is_array($value)){
foreach($value as $k => $v){
add_post_meta($pid, $key, $v, false);
}
}
}
}
$success = "Thank you for submitting.";
return (!empty($pid) && is_numeric($pid)) ? array('success' => "$success $imageUplodMsg $msgVid") : array('error' => 'An error occured. Please try again.');
}
}