【问题标题】:How to upload user profile multiple image from frontend in wordpress?如何从wordpress的前端上传用户个人资料多张图片?
【发布时间】:2015-03-19 13:24:35
【问题描述】:

我在前端创建了我的自定义注册表单插件。现在我需要该用户可以上传多个图像并将其保存在用户表中,并将其保存在用户配置文件文件夹中。我使用了很多插件,比如 Custom User Profile PhotoMetronet Profile Picture 但它不能正常工作。所以请建议我正确的方法。

【问题讨论】:

  • 您可以为此使用高级自定义字段插件

标签: wordpress plugins user-profile image-upload user-registration


【解决方案1】:
function imageupload($imagename){  
    $uploadedfile = $imagename;
    $upload_overrides = array( 'test_form' => false );
    $movefile = wp_handle_upload( $uploadedfile, $upload_overrides );
   if ( $movefile && !isset( $movefile['error'] ) ) 
   {
       $wp_filetype = $movefile['type'];
       $filename = $movefile['file'];
       $wp_upload_dir = wp_upload_dir();
       $attachment = array(
         'guid' => $wp_upload_dir['url'] . '/' . basename( $filename ),
         'post_mime_type' => $wp_filetype,
         'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
         'post_content' => '',
         'post_status' => 'inherit'
           );
      $attach_id = wp_insert_attachment( $attachment, $filename);
      $attach_data = wp_generate_attachment_metadata( $attach_id, $filename );
      wp_update_attachment_metadata( $attach_id,  $attach_data );
    } 
    else
    {
       echo $movefile['error'];
    }       
    }     
   $uploadedfile3 = $_FILES['idcard'];  /* First image */
   imageupload($uploadedfile3);
   $uploadedfile1 = $_FILES['Licence']; /*second image*/
   imageupload($uploadedfile1);
   $uploadedfile2 = $_FILES['Agreement']; /*next image*/
   imageupload($uploadedfile2);

【讨论】:

猜你喜欢
  • 2014-01-11
  • 1970-01-01
  • 2011-09-14
  • 1970-01-01
  • 1970-01-01
  • 2020-11-02
  • 2017-05-04
  • 2015-10-30
  • 1970-01-01
相关资源
最近更新 更多