Você está na página 1de 7

<div class="entry-content">

<?php

/* Load the registration file. */

/* If profile was saved, update profile. */


if ( 'POST' == $_SERVER['REQUEST_METHOD'] && !empty( $_POST['action'] ) &&
$_POST['action'] == 'update-user' ) {

/* Update user password. */


if ( !empty($_POST['pass1'] ) && !empty( $_POST['pass2'] ) ) {
if ( $_POST['pass1'] == $_POST['pass2'] )
wp_update_user( array( 'ID' => $aluno_info->id, 'user_pass'
=> esc_attr( $_POST['pass1'] ) ) );
else
$error = __('The passwords you entered do not match. Your
password was not updated.', 'frontendprofile');
}

/* Update user information. */

update_usermeta( $aluno_info->id, 'first_name',


esc_attr( $_POST['first_name'] ) );

update_usermeta( $aluno_info->id, 'last_name',


esc_attr( $_POST['last_name'] ) );

if ( !empty( $_POST['nickname'] ) )
update_usermeta( $aluno_info->id, 'nickname',
esc_attr( $_POST['nickname'] ) );

update_usermeta( $aluno_info->id, 'display_name',


esc_attr( $_POST['display_name'] ) );

if ( !empty( $_POST['email'] ) )
update_usermeta( $aluno_info->id, 'user_email',
esc_attr( $_POST['email'] ) );

if(strpos($_POST['website'], 'ttp://') || empty( $_POST['website'] ))


update_usermeta( $aluno_info->id, 'user_url',
esc_attr( $_POST['website'] ) );
else
update_usermeta( $aluno_info->id, 'user_url', 'http://' .
esc_attr( $_POST['website'] ) );

update_usermeta( $aluno_info->id, 'aim', esc_attr( $_POST['aim'] ) );

update_usermeta( $aluno_info->id, 'yim', esc_attr( $_POST['yim'] ) );

update_usermeta( $aluno_info->id, 'jabber',


esc_attr( $_POST['jabber'] ) );

update_usermeta( $aluno_info->id, 'description',


esc_attr( $_POST['description'] ) );

// Extra Profile Information

update_usermeta( $aluno_info->id, 'twitter',


esc_attr( $_POST['twitter'] ) );
update_usermeta( $aluno_info->id, 'birth',
esc_attr( $_POST['birth'] ) );

update_usermeta( $aluno_info->id, 'hobbies', $_POST['hobbies'] );

update_usermeta( $aluno_info->id, 'situacao',


esc_attr( $_POST['situacao'] ) );

/* Redirect so the page will show updated info. */


if ( !$error ) {
echo "<br>Atualizado!<br>";
//wp_redirect( get_permalink() );
//exit;
}
}// post

?>

<!-- EDIT PROFILE STARTS HERE -->

<?php if ( !is_user_logged_in() ) : ?>

<p class="warning">
<?php _e('You must be logged in to edit your
profile.', 'frontendprofile'); ?>
</p><!-- .warning -->

<?php else : ?>

<?php if ( $error ) echo '<p class="error">' . $error .


'</p>'; ?>

<form method="post" id="edituser" class="user-forms"


action="">

<strong>Name</strong>

<p class="first_name">
<label for="first_name"><?php _e('First Name',
'frontendprofile'); ?></label>
<input class="text-input" name="first_name"
type="text" id="first_name" value="<?php the_author_meta( 'first_name',
$aluno_info->id ); ?>" />
</p><!-- .first_name -->

<p class="last_name">
<label for="last_name"><?php _e('Last Name',
'frontendprofile'); ?></label>
<input class="text-input" name="last_name"
type="text" id="last_name" value="<?php the_author_meta( 'last_name', $aluno_info-
>id ); ?>" />
</p><!-- .last_name -->

<p class="display_name">
<label for="display_name"><?php _e('Display Name',
'frontendprofile'); ?></label>
<select name="display_name" id="display_name">
<?php
$public_display = array();
$public_display['display_nickname'] =
$aluno_info->nickname;
$public_display['display_username'] =
$aluno_info->user_login;
if ( !empty($aluno_info->first_name) )
$public_display['display_firstname'] =
$aluno_info->first_name;
if ( !empty($aluno_info->last_name) )
$public_display['display_lastname'] =
$aluno_info->last_name;
if ( !empty($aluno_info->first_name) && !
empty($aluno_info->last_name) ) {
$public_display['display_firstlast'] =
$aluno_info->first_name . ' ' . $aluno_info->last_name;
$public_display['display_lastfirst'] =
$aluno_info->last_name . ' ' . $aluno_info->first_name;
}
if ( !in_array( $aluno_info->display_name,
$public_display ) )// Only add this if it isn't duplicated elsewhere
$public_display =
array( 'display_displayname' => $aluno_info->display_name ) + $public_display;
$public_display = array_map( 'trim',
$public_display );
foreach ( $public_display as $id => $item ) {
?>
<option id="<?php echo $id; ?>" value="<?php
echo esc_attr($item); ?>"<?php selected( $aluno_info->display_name, $item ); ?>><?
php echo $item; ?></option>
<?php
}
?>
</select>
</p><!-- .display_name -->

<p class="form-nucleo">N�cleo
<?php
$args = array('cat'=>$cat_nucleos,'author'=>$current_user-
>ID,'order'=>'ASC','posts_per_page' => -1);query_posts($args);
echo '<select name="new_nucleo" id="new_nucleo">';
echo '<option value="">Alterar N�cleo para�</option>';
if(have_posts()) : while (have_posts()) : the_post();
$nome_nucleo = get_the_title();
$id_nucleo = get_the_ID();
if($id_nucleo == $nucleo_aluno ) $selected = 'selected="slelected"';
else $selected = '';
echo '<option value="' . $nome_nucleo . '" ' . $selected . '>' . $nome_nucleo .
'</option>';
endwhile; endif;
echo '</select>';
?>
</p><!-- .form-nucleo -->
<p class="form-curso">Curso
<?php
$args = array('cat'=>$cat_cursos,'author'=>$current_user-
>ID,'order'=>'ASC','posts_per_page' => -1);query_posts($args);
echo '<select name="new_curso" id="new_curso">';
echo '<option value="">Alterar Curso para�</option>';
if(have_posts()) : while (have_posts()) : the_post();
$nome_curso = get_the_title();
$id_curso = get_the_ID();
if($id_curso == $curso_aluno ) $selected = 'selected="slelected"';
else $selected = '';
echo '<option value="' . $nome_curso . '" ' . $selected . '>' . $nome_curso .
'</option>';
endwhile; endif;
echo '</select>';
?>
</p><!-- .form-curso -->
<p class="form-turma">Turma
<?php
$args = array('cat'=>$cat_turmas,'author'=>$current_user-
>ID,'order'=>'ASC','posts_per_page' => -1);query_posts($args);
echo '<select name="new_turma" id="new_turma">';
echo '<option value="">Alterar Turma para�</option>';
if(have_posts()) : while (have_posts()) : the_post();
$nome_turma = get_the_title();
$id_turma = get_the_ID();
if($id_turma == $turma_aluno ) $selected = 'selected="slelected"';
else $selected = '';
echo '<option value="' . $nome_turma . '" ' . $selected . '>' . $nome_turma .
'</option>';
endwhile; endif;
echo '</select>';
?>
</p><!-- .form-turma -->

<strong>Contact Info</strong>

<p class="form-email">
<label for="email"><?php _e('E-mail (required)',
'frontendprofile'); ?></label>
<input class="text-input" name="email" type="text"
id="email" value="<?php the_author_meta( 'user_email', $aluno_info->id ); ?>" />
</p><!-- .form-email -->

<p class="form-website">
<label for="website"><?php _e('Website',
'frontendprofile'); ?></label>
<input class="text-input" name="website" type="text"
id="website" value="<?php the_author_meta( 'user_url', $aluno_info->id ); ?>" />
</p><!-- .form-website -->

<p class="form-aim">
<label for="aim"><?php _e('AIM',
'frontendprofile'); ?></label>
<input class="text-input" name="aim" type="text"
id="aim" value="<?php the_author_meta( 'aim', $aluno_info->id ); ?>" />
</p><!-- .form-aim -->

<p class="form-yim">
<label for="yim"><?php _e('Yahoo IM',
'frontendprofile'); ?></label>
<input class="text-input" name="yim" type="text"
id="yim" value="<?php the_author_meta( 'yim', $aluno_info->id ); ?>" />
</p><!-- .form-yim -->

<p class="form-jabber">
<label for="jabber"><?php _e('Jabber / Google Talk',
'frontendprofile'); ?></label>
<input class="text-input" name="jabber" type="text"
id="jabber" value="<?php the_author_meta( 'jabber', $aluno_info->id ); ?>" />
</p><!-- .form-jabber -->

<strong>About Yourself</strong>

<p class="form-description">
<label for="description"><?php _e('Biographical
Info', 'frontendprofile'); ?></label>
<textarea class="text-input" name="description"
id="description" rows="5" cols="30"><?php echo the_author_meta( 'description',
$aluno_info->id ); ?></textarea>
</p><!-- .form-description -->

<p class="form-password">
<label for="pass1"><?php _e('New Password',
'frontendprofile'); ?> </label>
<input class="text-input" name="pass1"
type="password" id="pass1" />
</p><!-- .form-password -->

<p class="form-password">
<label for="pass2"><?php _e('Repeat Password',
'frontendprofile'); ?></label>
<input class="text-input" name="pass2"
type="password" id="pass2" />
</p><!-- .form-password -->

<strong>Extra Profile Information</strong>

<p class="form-twitter">
<label for="twitter"><?php _e('Twitter',
'frontendprofile'); ?></label>
<input class="text-input" name="twitter" type="text"
id="twitter" value="<?php the_author_meta( 'twitter', $aluno_info->id ); ?>" />
</p><!-- .form-twitter -->

<p class="form-birth">
<label for="birth"><?php _e('Year of birth',
'frontendprofile'); ?></label>
<?php
for($i=1900; $i<=2000; $i++)
$years[]=$i;

echo '<select name="birth">';


echo '<option value="">' . __("Select
Year", 'frontendprofile' ) . '</option>';
foreach($years as $year){
$the_year =
get_the_author_meta( 'birth', $aluno_info->id );
if($year == $the_year ) $selected =
'selected="slelected"';
else $selected = '';
echo '<option value="' . $year . '"
' . $selected . '>' . $year . '</option>';
}
echo '</select>';
?>
</p><!-- .form-birth -->

<p class="form-hobbies">
<label for="hobbies"><?php _e('What are your
hobbies?', 'frontendprofile'); ?></label>
<?php
$hobbies = get_the_author_meta( 'hobbies',
$aluno_info->id );
?>
<ul class="hobbies-type-list">
<li><input value="videogames"
name="hobbies[]" <?php if (is_array($hobbies)) { if (in_array("videogames",
$hobbies)) { ?>checked="checked"<?php } }?> type="checkbox" /> <?php _e('Video
Games', 'frontendprofile'); ?></li>
<li><input value="sabotagingcapitalism"
name="hobbies[]" <?php if (is_array($hobbies)) { if
(in_array("sabotagingcapitalism", $hobbies)) { ?>checked="checked"<?php } }?>
type="checkbox" /> <?php _e('Sabotaging Capitalism', 'frontendprofile'); ?></li>
<li><input value="watchingtv"
name="hobbies[]" <?php if (is_array($hobbies)) { if (in_array("watchingtv",
$hobbies)) { ?>checked="checked"<?php } }?> type="checkbox" /> <?php _e('Watching
TV', 'frontendprofile'); ?></li>
</ul>
</p><!-- .form-hobbies -->

<p class="form-situacao">
<label for="situacao"><?php _e('Situa��o financeira',
'frontendprofile'); ?></label>
<?php $situacao = get_the_author_meta( 'situacao',
$aluno_info->ID ); ?>
<ul>
<li><input value="ag" name="situacao" <?php if
($situacao == 'ag' ) { ?>checked="checked"<?php }?> type="radio" /> <?php
_e('Aguardando', 'frontendprofile'); ?></li>
<li><input value="ed" name="situacao" <?php if
($situacao == 'ed' ) { ?>checked="checked"<?php }?> type="radio" /> <?php _e('Em
dia', 'frontendprofile'); ?></li>
<li><input value="qt" name="situacao" <?php if
($situacao == 'qt' ) { ?>checked="checked"<?php }?> type="radio" /> <?php
_e('Quitado', 'frontendprofile'); ?></li>
<li><input value="at" name="situacao" <?php if
($situacao == 'at' ) { ?>checked="checked"<?php }?> type="radio" /> <?php
_e('Atrasado', 'frontendprofile'); ?></li>
</ul>
</p><!-- .form-situacao -->

<p class="form-submit">
<?php echo $referer; ?>
<input name="updateuser" type="submit"
id="updateuser" class="submit button" value="<?php _e('Update', 'frontendprofile');
?>" />
<?php wp_nonce_field( 'update-user' ) ?>
<input name="action" type="hidden" id="action"
value="update-user" />
</p><!-- .form-submit -->
</form><!-- #edituser -->

<?php endif; ?>


</div>

Você também pode gostar