Hey folks,
I am writing a rather extensive alteration of the user profile page. Among the alterations I need users to be able to upload a pdf file.
What I need help with is how to actually handle the pdf file, so it gets uploaded preferable with username_ prepended to filename (bob_specs.pdf)
What I have so far:
///////////// PDF upload //////////////////
add_action( 'show_user_profile', 'pdf_upload' );
add_action( 'edit_user_profile', 'pdf_upload' );
function pdf_upload( $user ) { ?>
<table class="form-table">
<h3>Upload PDF specifications</h3>
<span>tutorial</span>
<tr>
<th><label for="pdf">PDF</label></th>
<td>
<input type="file" name="pdf" id="pdf" value="<?php echo esc_attr( get_the_author_meta( 'pdf', $user->ID ) ); ?>" class="regular-text" /><input type='button' class="upl button-primary" value="Upload PDF" id="uploadpdf"/><br />
<span class="description">Please choose a PDF file to upload</span>
</td>
</tr>
</table>
<?php }
///////////// PDF upload END //////////////////
This only adds the upload form to the profile page. So I am missing the actual handling of the file.
after successful upload I call this in my author.php file
<?php $user = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author')); ?>
....
<?php echo $user->pdf; ?>
....
Any inputs, advice, or code examples would be greatly appreciated.
PS. not looking for plugins