PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Display Uploaded Files in the Backend

  1. I'm looking for a way to display the results of a User's uploaded file in the backend, as well offer the ability to change it from there. I may be off with what I've got so far. It seems to work fine when the user first submits the registration form (I'm using the User Registration Addon).

    I'm adding extra fields to the user profiles in the backend like this - and it kind of works - but when you edit from the backend, the file path is wrong. I'd also like to just display the filename as a link to the full path.

    add_action( 'show_user_profile', 'add_student_extra_profile_fields' );
    add_action( 'edit_user_profile', 'add_student_extra_profile_fields' );
    
    .... proper table setup to ...
    
    <tr>
      <th><label for="record_upload">File Change</label></th>
        <td>
            <input type="file" name="record_upload" id="record_upload" value="<?php echo esc_attr( get_the_author_meta( 'record_upload', $user->ID ) ); ?>" class="regular-text" />
           <span class="description">Please upload a scanned copy of your Academic Record, if available.</span>
          </td>
        </tr>
      <tr>
      <td>Uploaded Academic File</td>
      <td>
        <p class="file-display clear">
            <a href="<?php echo esc_attr( get_the_author_meta( 'record_upload', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'record_upload', $user->ID ) ); ?></a>
        </p>
      </td>
    </tr>
    
    ... finish up the table etc. ...
    
    add_action( 'personal_options_update', 'save_student_extra_profile_fields' );
    add_action( 'edit_user_profile_update', 'save_student_extra_profile_fields' );
    
    function save_student_extra_profile_fields( $user_id ) {
    
    	if ( !current_user_can( 'edit_user', $user_id ) )
    		return false;
    
    	update_usermeta( $user_id, 'record_upload', $_POST['record_upload'] );
    }
    Posted 11 years ago on Saturday March 16, 2013 | Permalink
  2. As this isn't a support issue, but more of a customization - we'll leave this thread open for the community to chime in on if anyone has any helpful ideas.

    Posted 11 years ago on Sunday March 17, 2013 | Permalink