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'] );
}