<?php
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) {
$r = get_user_meta( $user->ID, 'picture', true );
?>
<?php if( current_user_can( 'administrator' ) ){ ?>
<h3>Set User Type</h3>
<table class="form-table">
<tr>
<th><label FOR="acctype">User Type:</label></th>
<td>
<select name="acctype">
<option value="<?php echo esc_attr( get_the_author_meta( 'acctype', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'acctype', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="artists">Artist</option>
<option value="songwriters">Songwriter</option>
</select>
</td>
</tr>
</table>
<?php } ?>
<?php
if ((get_the_author_meta( 'acctype', $user->ID ))=="") {
}
else { ?>
</br><h2>Public Artist Profile</h2>
<!-- Social Networking Profile Infomation -->
<h3><?php _e("Public Profile - Social", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="website"><?php _e("Website:"); ?></label></th>
<td>http://
<input type="text" name="website" id="website" value="<?php echo esc_attr( get_the_author_meta( 'website', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="cemail"><?php _e("Contact Email:"); ?></label></th>
<td>
<input type="text" name="cemail" id="cemail" value="<?php echo esc_attr( get_the_author_meta( 'cemail', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="twitter"><?php _e("Twitter Username:"); ?></label></th>
<td>
@
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="facebook"><?php _e("Facebook Page:"); ?></label></th>
<td>
www.facebook.com/
<input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="stumble"><?php _e("Stumble Upon Page:"); ?></label></th>
<td>
www.stumbleupon.com/
<input type="text" name="stumble" id="stumble" value="<?php echo esc_attr( get_the_author_meta( 'stumble', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="videop"><?php _e("YouTube Profile Page:"); ?></label></th>
<td>
www.youtube.com/user/
<input type="text" name="videop" id="videop" value="<?php echo esc_attr( get_the_author_meta( 'videop', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="soundcloud"><?php _e("SoundCloud Page:"); ?></label></th>
<td>
wwww.soundcloud.com/
<input type="text" name="soundcloud" id="soundcloud" value="<?php echo esc_attr( get_the_author_meta( 'soundcloud', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="itunes"><?php _e("iTunes URL:"); ?></label></th>
<td>
http://
<input type="text" name="itunes" id="itunes" value="<?php echo esc_attr( get_the_author_meta( 'itunes', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist About Information -->
<h3><?php _e("Public Profile - About", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="artistname"><?php _e("Artist Name*:"); ?></label></th>
<td>
<input type="text" name="artistname" id="artistname" value="<?php echo esc_attr( get_the_author_meta( 'artistname', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="bioabout"><?php _e("Biography"); ?></label></th>
<td>
<textarea rows="10" cols="30" name="bioabout" id="bioabout" class="regular-text" ><?php echo esc_attr( get_the_author_meta( 'bioabout', $user->ID ) ); ?></textarea>
</td>
</tr>
<?php
if ((get_the_author_meta( 'acctype', $user->ID ))=="artists") { ?>
<tr>
<th><label for="instrument"><?php _e("Type of Act:"); ?></label></th>
<td>
<select name="instrument">
<option value="<?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="Singer">Singer</option>
<option value="Singer/Guitarist">Singer/Guitarist</option>
<option value="Girl Band">Girl Band</option>
<option value="Boy Band">Boy Band</option>
<option value="Instrumental Group">Instrumental Group</option>
<option value="Band">Band</option>
<option value="Trio">Trio</option>
<option value="Quartet">Quartet</option>
<option value="Duet">Duet</option>
<option value="Street Performer">Street Performer</option>
<option value="Large Pnsemble">Large Ensemble</option>
<option value="Instrumental">SoloistInstrumental Soloist</option>
<option value="Big Band">Big Band</option>
<option value="DJ">DJ</option>
<option value="Solo Act">Solo Act</option>
<option value="Showband">Showband</option>
<option value="Cover Band">Cover Band</option>
<option value="Function Band">Function Band</option>
<option value="Accompanist">Accompanist</option>
<option value="Other">Other</option>
</select><br />
</td>
</tr>
<?php
}
else
{ ?>
<tr>
<th><label for="instrument"><?php _e("Specialism:"); ?></label></th>
<td>
<select name="instrument">
<option value="<?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="Songwriter">Songwriter</option>
<option value="Arranger">Arranger</option>
<option value="Composer">Composer</option>
<option value="Lyricist">Lyricist</option>
<option value="Lyricist & Songwriter">Lyricist & Songwriter</option>
<option value="Composer & Arranger">Composer & Arranger</option>
<option value="Collaborator">Collaborator</option>
<option value="Remixes">Remixes</option>
<option value="Orchestrater">Orchestrater</option>
</select><br />
</td>
</tr>
<?php }
?>
<tr>
<th><label for="location"><?php _e("Location:"); ?></label></th>
<td>
<input type="text" name="location" id="location" value="<?php echo esc_attr( get_the_author_meta( 'location', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="avatar"><?php _e("Profile Pic:"); ?></label></th>
<td>
<input type="text" name="avatar" id="avatar" value="<?php echo esc_attr( get_the_author_meta( 'avatar', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist Music -->
<h3><?php _e("Public Profile - Listen", "blank"); ?></h3>
<span class="description">Login or create a <a href="http://soundcloud.com">soundcloud</a> account to upload your tracks. Once logged in, create a <a href="http://soundcloud.com/sets/new">new set</a> and add your songs. Be sure to arrange your tracks into order whilst on soundcloud as you will not be able to edit them once they are on the Parloscope website. Once completed, copy the embedded code of the widget and paste it in the box below. Don't worry about your album artwork, it should upload automatically. Hey Presto - you are all done!</span>
<table class="form-table">
<tr>
<th><label for="scembed"><?php _e("SoundCloud Widget Embed Code:"); ?></label></th>
<td>
<textarea rows="10" cols="30" name="scembed" id="scembed" class="regular-text" ><?php echo esc_attr( get_the_author_meta( 'scembed', $user->ID ) ); ?></textarea>
</td>
</tr>
</table>
<!-- Artist Video -->
<h3><?php _e("Public Profile - Watch", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="fvideo"><?php _e("Featured YouTube Video:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="fvideo" id="fvideo" value="<?php echo esc_attr( get_the_author_meta( 'fvideo', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="video1"><?php _e("YouTube Video 1:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="video1" id="video1" value="<?php echo esc_attr( get_the_author_meta( 'video1', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="video2"><?php _e("YouTube Video 2:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="video2" id="video2" value="<?php echo esc_attr( get_the_author_meta( 'video2', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist Photo Gallery -->
<h3><?php _e("Public Profile - Gallery", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="fimage"><?php _e("Featured Image URL:"); ?></label></th>
<td>
<input type="text" name="fimage" id="fimage" value="<?php echo esc_attr( get_the_author_meta( 'fimage', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="moreimages"><?php _e("Image Website:"); ?></label></th>
<td>
http://
<input type="text" name="moreimages" id="moreimages" value="<?php echo esc_attr( get_the_author_meta( 'moreimages', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">If you have more online images elsewhere (such as Flickr, Picassa, Photobucket, etc) provide the URL to connect visitors</span>
</td>
</tr>
<tr>
<th scope="row">Picture</th>
<td><input type="file" name="picture" value="" />
<?php //print_r($r);
if (!isset($r['error'])) {
$r = $r['url'];
echo "<img src='$r' />";
} else {
$r = $r['error'];
echo $r;
}
?>
</td>
</tr>
</table>
<?php }
}
add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
$_POST['action'] = 'wp_handle_upload';
$r = wp_handle_upload( $_FILES['picture'] );
update_user_meta( $user_id, 'picture', $r, get_user_meta( $user_id, 'picture', true ) );
// Add Social Fields
update_user_meta( $user_id, 'website', $_POST['website'] );
update_user_meta( $user_id, 'cemail', $_POST['cemail'] );
update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
update_user_meta( $user_id, 'stumble', $_POST['stumble'] );
update_user_meta( $user_id, 'itunes', $_POST['itunes'] );
update_user_meta( $user_id, 'soundcloud', $_POST['soundcloud'] );
update_user_meta( $user_id, 'youtube', $_POST['youtube'] );
// Add About Fields
update_user_meta( $user_id, 'bioabout', $_POST['bioabout'] );
update_user_meta( $user_id, 'artistname', $_POST['artistname'] );
update_user_meta( $user_id, 'genre', $_POST['genre'] );
update_user_meta( $user_id, 'genre2', $_POST['genre2'] );
update_user_meta( $user_id, 'genre3', $_POST['genre3'] );
update_user_meta( $user_id, 'instrument', $_POST['instrument'] );
update_user_meta( $user_id, 'location', $_POST['location'] );
update_user_meta( $user_id, 'avatar', $_POST['avatar'] );
// Add Gallery Fields
update_user_meta( $user_id, 'fimage', $_POST['fimage'] );
update_user_meta( $user_id, 'moreimages', $_POST['moreimages'] );
// Add Video Fields
update_user_meta( $user_id, 'fvideo', $_POST['fvideo'] );
update_user_meta( $user_id, 'video1', $_POST['video1'] );
update_user_meta( $user_id, 'video2', $_POST['video2'] );
update_user_meta( $user_id, 'videop', $_POST['videop'] );
// Add Audio Fields
update_user_meta( $user_id, 'scembed', $_POST['scembed'] );
if( current_user_can( 'administrator' ) ){
update_user_meta( $user_id, 'acctype', $_POST['acctype'] );
}
}
add_action('user_edit_form_tag', 'make_form_accept_uploads');
function make_form_accept_uploads() {
echo ' enctype="multipart/form-data"';
}
<?php
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) {
$r = get_user_meta( $user->ID, 'picture', true );
?>
<?php if( current_user_can( 'administrator' ) ){ ?>
<h3>Set User Type</h3>
<table class="form-table">
<tr>
<th><label FOR="acctype">User Type:</label></th>
<td>
<select name="acctype">
<option value="<?php echo esc_attr( get_the_author_meta( 'acctype', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'acctype', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="artists">Artist</option>
<option value="songwriters">Songwriter</option>
</select>
</td>
</tr>
</table>
<?php } ?>
<?php
if ((get_the_author_meta( 'acctype', $user->ID ))=="") {
}
else { ?>
</br><h2>Public Artist Profile</h2>
<!-- Social Networking Profile Infomation -->
<h3><?php _e("Public Profile - Social", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="website"><?php _e("Website:"); ?></label></th>
<td>http://
<input type="text" name="website" id="website" value="<?php echo esc_attr( get_the_author_meta( 'website', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="cemail"><?php _e("Contact Email:"); ?></label></th>
<td>
<input type="text" name="cemail" id="cemail" value="<?php echo esc_attr( get_the_author_meta( 'cemail', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="twitter"><?php _e("Twitter Username:"); ?></label></th>
<td>
@
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="facebook"><?php _e("Facebook Page:"); ?></label></th>
<td>
www.facebook.com/
<input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="stumble"><?php _e("Stumble Upon Page:"); ?></label></th>
<td>
www.stumbleupon.com/
<input type="text" name="stumble" id="stumble" value="<?php echo esc_attr( get_the_author_meta( 'stumble', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="videop"><?php _e("YouTube Profile Page:"); ?></label></th>
<td>
www.youtube.com/user/
<input type="text" name="videop" id="videop" value="<?php echo esc_attr( get_the_author_meta( 'videop', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="soundcloud"><?php _e("SoundCloud Page:"); ?></label></th>
<td>
wwww.soundcloud.com/
<input type="text" name="soundcloud" id="soundcloud" value="<?php echo esc_attr( get_the_author_meta( 'soundcloud', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="itunes"><?php _e("iTunes URL:"); ?></label></th>
<td>
http://
<input type="text" name="itunes" id="itunes" value="<?php echo esc_attr( get_the_author_meta( 'itunes', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist About Information -->
<h3><?php _e("Public Profile - About", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="artistname"><?php _e("Artist Name*:"); ?></label></th>
<td>
<input type="text" name="artistname" id="artistname" value="<?php echo esc_attr( get_the_author_meta( 'artistname', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="bioabout"><?php _e("Biography"); ?></label></th>
<td>
<textarea rows="10" cols="30" name="bioabout" id="bioabout" class="regular-text" ><?php echo esc_attr( get_the_author_meta( 'bioabout', $user->ID ) ); ?></textarea>
</td>
</tr>
<?php
if ((get_the_author_meta( 'acctype', $user->ID ))=="artists") { ?>
<tr>
<th><label for="instrument"><?php _e("Type of Act:"); ?></label></th>
<td>
<select name="instrument">
<option value="<?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="Singer">Singer</option>
<option value="Singer/Guitarist">Singer/Guitarist</option>
<option value="Girl Band">Girl Band</option>
<option value="Boy Band">Boy Band</option>
<option value="Instrumental Group">Instrumental Group</option>
<option value="Band">Band</option>
<option value="Trio">Trio</option>
<option value="Quartet">Quartet</option>
<option value="Duet">Duet</option>
<option value="Street Performer">Street Performer</option>
<option value="Large Pnsemble">Large Ensemble</option>
<option value="Instrumental">SoloistInstrumental Soloist</option>
<option value="Big Band">Big Band</option>
<option value="DJ">DJ</option>
<option value="Solo Act">Solo Act</option>
<option value="Showband">Showband</option>
<option value="Cover Band">Cover Band</option>
<option value="Function Band">Function Band</option>
<option value="Accompanist">Accompanist</option>
<option value="Other">Other</option>
</select><br />
</td>
</tr>
<?php
}
else
{ ?>
<tr>
<th><label for="instrument"><?php _e("Specialism:"); ?></label></th>
<td>
<select name="instrument">
<option value="<?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="Songwriter">Songwriter</option>
<option value="Arranger">Arranger</option>
<option value="Composer">Composer</option>
<option value="Lyricist">Lyricist</option>
<option value="Lyricist & Songwriter">Lyricist & Songwriter</option>
<option value="Composer & Arranger">Composer & Arranger</option>
<option value="Collaborator">Collaborator</option>
<option value="Remixes">Remixes</option>
<option value="Orchestrater">Orchestrater</option>
</select><br />
</td>
</tr>
<?php }
?>
<tr>
<th><label for="location"><?php _e("Location:"); ?></label></th>
<td>
<input type="text" name="location" id="location" value="<?php echo esc_attr( get_the_author_meta( 'location', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="avatar"><?php _e("Profile Pic:"); ?></label></th>
<td>
<input type="text" name="avatar" id="avatar" value="<?php echo esc_attr( get_the_author_meta( 'avatar', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist Music -->
<h3><?php _e("Public Profile - Listen", "blank"); ?></h3>
<span class="description">Login or create a <a href="http://soundcloud.com">soundcloud</a> account to upload your tracks. Once logged in, create a <a href="http://soundcloud.com/sets/new">new set</a> and add your songs. Be sure to arrange your tracks into order whilst on soundcloud as you will not be able to edit them once they are on the Parloscope website. Once completed, copy the embedded code of the widget and paste it in the box below. Don't worry about your album artwork, it should upload automatically. Hey Presto - you are all done!</span>
<table class="form-table">
<tr>
<th><label for="scembed"><?php _e("SoundCloud Widget Embed Code:"); ?></label></th>
<td>
<textarea rows="10" cols="30" name="scembed" id="scembed" class="regular-text" ><?php echo esc_attr( get_the_author_meta( 'scembed', $user->ID ) ); ?></textarea>
</td>
</tr>
</table>
<!-- Artist Video -->
<h3><?php _e("Public Profile - Watch", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="fvideo"><?php _e("Featured YouTube Video:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="fvideo" id="fvideo" value="<?php echo esc_attr( get_the_author_meta( 'fvideo', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="video1"><?php _e("YouTube Video 1:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="video1" id="video1" value="<?php echo esc_attr( get_the_author_meta( 'video1', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="video2"><?php _e("YouTube Video 2:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="video2" id="video2" value="<?php echo esc_attr( get_the_author_meta( 'video2', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist Photo Gallery -->
<h3><?php _e("Public Profile - Gallery", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="fimage"><?php _e("Featured Image URL:"); ?></label></th>
<td>
<input type="text" name="fimage" id="fimage" value="<?php echo esc_attr( get_the_author_meta( 'fimage', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="moreimages"><?php _e("Image Website:"); ?></label></th>
<td>
http://
<input type="text" name="moreimages" id="moreimages" value="<?php echo esc_attr( get_the_author_meta( 'moreimages', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">If you have more online images elsewhere (such as Flickr, Picassa, Photobucket, etc) provide the URL to connect visitors</span>
</td>
</tr>
<tr>
<th scope="row">Picture</th>
<td><input type="file" name="picture" value="" />
<?php //print_r($r);
if (!isset($r['error'])) {
$r = $r['url'];
echo "<img src='$r' />";
} else {
$r = $r['error'];
echo $r;
}
?>
</td>
</tr>
</table>
<?php }
}
add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
$_POST['action'] = 'wp_handle_upload';
$r = wp_handle_upload( $_FILES['picture'] );
update_user_meta( $user_id, 'picture', $r, get_user_meta( $user_id, 'picture', true ) );
// Add Social Fields
update_user_meta( $user_id, 'website', $_POST['website'] );
update_user_meta( $user_id, 'cemail', $_POST['cemail'] );
update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
update_user_meta( $user_id, 'stumble', $_POST['stumble'] );
update_user_meta( $user_id, 'itunes', $_POST['itunes'] );
update_user_meta( $user_id, 'soundcloud', $_POST['soundcloud'] );
update_user_meta( $user_id, 'youtube', $_POST['youtube'] );
// Add About Fields
update_user_meta( $user_id, 'bioabout', $_POST['bioabout'] );
update_user_meta( $user_id, 'artistname', $_POST['artistname'] );
update_user_meta( $user_id, 'genre', $_POST['genre'] );
update_user_meta( $user_id, 'genre2', $_POST['genre2'] );
update_user_meta( $user_id, 'genre3', $_POST['genre3'] );
update_user_meta( $user_id, 'instrument', $_POST['instrument'] );
update_user_meta( $user_id, 'location', $_POST['location'] );
update_user_meta( $user_id, 'avatar', $_POST['avatar'] );
// Add Gallery Fields
update_user_meta( $user_id, 'fimage', $_POST['fimage'] );
update_user_meta( $user_id, 'moreimages', $_POST['moreimages'] );
// Add Video Fields
update_user_meta( $user_id, 'fvideo', $_POST['fvideo'] );
update_user_meta( $user_id, 'video1', $_POST['video1'] );
update_user_meta( $user_id, 'video2', $_POST['video2'] );
update_user_meta( $user_id, 'videop', $_POST['videop'] );
// Add Audio Fields
update_user_meta( $user_id, 'scembed', $_POST['scembed'] );
if( current_user_can( 'administrator' ) ){
update_user_meta( $user_id, 'acctype', $_POST['acctype'] );
}
}
add_action('user_edit_form_tag', 'make_form_accept_uploads');
function make_form_accept_uploads() {
echo ' enctype="multipart/form-data"';
}
<?php
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) {
$r = get_user_meta( $user->ID, 'picture', true );
?>
<!-- Artist Photo Gallery -->
<h3><?php _e("Public Profile - Gallery", "blank"); ?></h3>
<table class="form-table">
<tr>
<th scope="row">Picture</th>
<td><input type="file" name="picture" value="" />
<?php //print_r($r);
if (!isset($r['error'])) {
$r = $r['url'];
echo "<img src='$r' />";
} else {
$r = $r['error'];
echo $r;
}
?>
</td>
</tr>
</table>
<?php
}
add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
$_POST['action'] = 'wp_handle_upload';
$r = wp_handle_upload( $_FILES['picture'] );
update_user_meta( $user_id, 'picture', $r, get_user_meta( $user_id, 'picture', true ) );
}
}
add_action('user_edit_form_tag', 'make_form_accept_uploads');
function make_form_accept_uploads() {
echo ' enctype="multipart/form-data"';
}
Wordpress User Profile Upload - If page is saved file reset
I have various different extra profile fields which I have set in functions.php however with the upload one if a user uploads an image and saves the form the image is set, however if they go back and edit another field it sets the image field to null.
Here is the code I have in my functions.php file. Any help would be really appreciated.
<?php
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) {
$r = get_user_meta( $user->ID, 'picture', true );
?>
<?php if( current_user_can( 'administrator' ) ){ ?>
<h3>Set User Type</h3>
<table class="form-table">
<tr>
<th><label FOR="acctype">User Type:</label></th>
<td>
<select name="acctype">
<option value="<?php echo esc_attr( get_the_author_meta( 'acctype', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'acctype', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="artists">Artist</option>
<option value="songwriters">Songwriter</option>
</select>
</td>
</tr>
</table>
<?php } ?>
<?php
if ((get_the_author_meta( 'acctype', $user->ID ))=="") {
}
else { ?>
</br><h2>Public Artist Profile</h2>
<!-- Social Networking Profile Infomation -->
<h3><?php _e("Public Profile - Social", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="website"><?php _e("Website:"); ?></label></th>
<td>http://
<input type="text" name="website" id="website" value="<?php echo esc_attr( get_the_author_meta( 'website', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="cemail"><?php _e("Contact Email:"); ?></label></th>
<td>
<input type="text" name="cemail" id="cemail" value="<?php echo esc_attr( get_the_author_meta( 'cemail', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="twitter"><?php _e("Twitter Username:"); ?></label></th>
<td>
@
<input type="text" name="twitter" id="twitter" value="<?php echo esc_attr( get_the_author_meta( 'twitter', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="facebook"><?php _e("Facebook Page:"); ?></label></th>
<td>
www.facebook.com/
<input type="text" name="facebook" id="facebook" value="<?php echo esc_attr( get_the_author_meta( 'facebook', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="stumble"><?php _e("Stumble Upon Page:"); ?></label></th>
<td>
www.stumbleupon.com/
<input type="text" name="stumble" id="stumble" value="<?php echo esc_attr( get_the_author_meta( 'stumble', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="videop"><?php _e("YouTube Profile Page:"); ?></label></th>
<td>
www.youtube.com/user/
<input type="text" name="videop" id="videop" value="<?php echo esc_attr( get_the_author_meta( 'videop', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="soundcloud"><?php _e("SoundCloud Page:"); ?></label></th>
<td>
wwww.soundcloud.com/
<input type="text" name="soundcloud" id="soundcloud" value="<?php echo esc_attr( get_the_author_meta( 'soundcloud', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="itunes"><?php _e("iTunes URL:"); ?></label></th>
<td>
http://
<input type="text" name="itunes" id="itunes" value="<?php echo esc_attr( get_the_author_meta( 'itunes', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist About Information -->
<h3><?php _e("Public Profile - About", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="artistname"><?php _e("Artist Name*:"); ?></label></th>
<td>
<input type="text" name="artistname" id="artistname" value="<?php echo esc_attr( get_the_author_meta( 'artistname', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="bioabout"><?php _e("Biography"); ?></label></th>
<td>
<textarea rows="10" cols="30" name="bioabout" id="bioabout" class="regular-text" ><?php echo esc_attr( get_the_author_meta( 'bioabout', $user->ID ) ); ?></textarea>
</td>
</tr>
<?php
if ((get_the_author_meta( 'acctype', $user->ID ))=="artists") { ?>
<tr>
<th><label for="instrument"><?php _e("Type of Act:"); ?></label></th>
<td>
<select name="instrument">
<option value="<?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="Singer">Singer</option>
<option value="Singer/Guitarist">Singer/Guitarist</option>
<option value="Girl Band">Girl Band</option>
<option value="Boy Band">Boy Band</option>
<option value="Instrumental Group">Instrumental Group</option>
<option value="Band">Band</option>
<option value="Trio">Trio</option>
<option value="Quartet">Quartet</option>
<option value="Duet">Duet</option>
<option value="Street Performer">Street Performer</option>
<option value="Large Pnsemble">Large Ensemble</option>
<option value="Instrumental">SoloistInstrumental Soloist</option>
<option value="Big Band">Big Band</option>
<option value="DJ">DJ</option>
<option value="Solo Act">Solo Act</option>
<option value="Showband">Showband</option>
<option value="Cover Band">Cover Band</option>
<option value="Function Band">Function Band</option>
<option value="Accompanist">Accompanist</option>
<option value="Other">Other</option>
</select><br />
</td>
</tr>
<?php
}
else
{ ?>
<tr>
<th><label for="instrument"><?php _e("Specialism:"); ?></label></th>
<td>
<select name="instrument">
<option value="<?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?>"><?php echo esc_attr( get_the_author_meta( 'instrument', $user->ID ) ); ?></option>
<option value="">None</option>
<option value="Songwriter">Songwriter</option>
<option value="Arranger">Arranger</option>
<option value="Composer">Composer</option>
<option value="Lyricist">Lyricist</option>
<option value="Lyricist & Songwriter">Lyricist & Songwriter</option>
<option value="Composer & Arranger">Composer & Arranger</option>
<option value="Collaborator">Collaborator</option>
<option value="Remixes">Remixes</option>
<option value="Orchestrater">Orchestrater</option>
</select><br />
</td>
</tr>
<?php }
?>
<tr>
<th><label for="location"><?php _e("Location:"); ?></label></th>
<td>
<input type="text" name="location" id="location" value="<?php echo esc_attr( get_the_author_meta( 'location', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="avatar"><?php _e("Profile Pic:"); ?></label></th>
<td>
<input type="text" name="avatar" id="avatar" value="<?php echo esc_attr( get_the_author_meta( 'avatar', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist Music -->
<h3><?php _e("Public Profile - Listen", "blank"); ?></h3>
<span class="description">Login or create a <a href="http://soundcloud.com">soundcloud</a> account to upload your tracks. Once logged in, create a <a href="http://soundcloud.com/sets/new">new set</a> and add your songs. Be sure to arrange your tracks into order whilst on soundcloud as you will not be able to edit them once they are on the Parloscope website. Once completed, copy the embedded code of the widget and paste it in the box below. Don't worry about your album artwork, it should upload automatically. Hey Presto - you are all done!</span>
<table class="form-table">
<tr>
<th><label for="scembed"><?php _e("SoundCloud Widget Embed Code:"); ?></label></th>
<td>
<textarea rows="10" cols="30" name="scembed" id="scembed" class="regular-text" ><?php echo esc_attr( get_the_author_meta( 'scembed', $user->ID ) ); ?></textarea>
</td>
</tr>
</table>
<!-- Artist Video -->
<h3><?php _e("Public Profile - Watch", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="fvideo"><?php _e("Featured YouTube Video:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="fvideo" id="fvideo" value="<?php echo esc_attr( get_the_author_meta( 'fvideo', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="video1"><?php _e("YouTube Video 1:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="video1" id="video1" value="<?php echo esc_attr( get_the_author_meta( 'video1', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="video2"><?php _e("YouTube Video 2:"); ?></label></th>
<td>
www.youtube.com/
<input type="text" name="video2" id="video2" value="<?php echo esc_attr( get_the_author_meta( 'video2', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
</table>
<!-- Artist Photo Gallery -->
<h3><?php _e("Public Profile - Gallery", "blank"); ?></h3>
<table class="form-table">
<tr>
<th><label for="fimage"><?php _e("Featured Image URL:"); ?></label></th>
<td>
<input type="text" name="fimage" id="fimage" value="<?php echo esc_attr( get_the_author_meta( 'fimage', $user->ID ) ); ?>" class="regular-text" /><br />
</td>
</tr>
<tr>
<th><label for="moreimages"><?php _e("Image Website:"); ?></label></th>
<td>
http://
<input type="text" name="moreimages" id="moreimages" value="<?php echo esc_attr( get_the_author_meta( 'moreimages', $user->ID ) ); ?>" class="regular-text" /><br />
<span class="description">If you have more online images elsewhere (such as Flickr, Picassa, Photobucket, etc) provide the URL to connect visitors</span>
</td>
</tr>
<tr>
<th scope="row">Picture</th>
<td><input type="file" name="picture" value="" />
<?php //print_r($r);
if (!isset($r['error'])) {
$r = $r['url'];
echo "<img src='$r' />";
} else {
$r = $r['error'];
echo $r;
}
?>
</td>
</tr>
</table>
<?php }
}
add_action( 'personal_options_update', 'save_extra_user_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_user_profile_fields' );
function save_extra_user_profile_fields( $user_id ) {
if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }
$_POST['action'] = 'wp_handle_upload';
$r = wp_handle_upload( $_FILES['picture'] );
update_user_meta( $user_id, 'picture', $r, get_user_meta( $user_id, 'picture', true ) );
// Add Social Fields
update_user_meta( $user_id, 'website', $_POST['website'] );
update_user_meta( $user_id, 'cemail', $_POST['cemail'] );
update_user_meta( $user_id, 'twitter', $_POST['twitter'] );
update_user_meta( $user_id, 'facebook', $_POST['facebook'] );
update_user_meta( $user_id, 'stumble', $_POST['stumble'] );
update_user_meta( $user_id, 'itunes', $_POST['itunes'] );
update_user_meta( $user_id, 'soundcloud', $_POST['soundcloud'] );
update_user_meta( $user_id, 'youtube', $_POST['youtube'] );
// Add About Fields
update_user_meta( $user_id, 'bioabout', $_POST['bioabout'] );
update_user_meta( $user_id, 'artistname', $_POST['artistname'] );
update_user_meta( $user_id, 'genre', $_POST['genre'] );
update_user_meta( $user_id, 'genre2', $_POST['genre2'] );
update_user_meta( $user_id, 'genre3', $_POST['genre3'] );
update_user_meta( $user_id, 'instrument', $_POST['instrument'] );
update_user_meta( $user_id, 'location', $_POST['location'] );
update_user_meta( $user_id, 'avatar', $_POST['avatar'] );
// Add Gallery Fields
update_user_meta( $user_id, 'fimage', $_POST['fimage'] );
update_user_meta( $user_id, 'moreimages', $_POST['moreimages'] );
// Add Video Fields
update_user_meta( $user_id, 'fvideo', $_POST['fvideo'] );
update_user_meta( $user_id, 'video1', $_POST['video1'] );
update_user_meta( $user_id, 'video2', $_POST['video2'] );
update_user_meta( $user_id, 'videop', $_POST['videop'] );
// Add Audio Fields
update_user_meta( $user_id, 'scembed', $_POST['scembed'] );
if( current_user_can( 'administrator' ) ){
update_user_meta( $user_id, 'acctype', $_POST['acctype'] );
}
}
add_action('user_edit_form_tag', 'make_form_accept_uploads');
function make_form_accept_uploads() {
echo ' enctype="multipart/form-data"';
}
default