All pastes #2109391 Raw Edit

wp_editor api issue

public text v1 · immutable
#2109391 ·published 2012-02-03 15:39 UTC
rendered paste body
//ADD EXTRA FIELDS TO USER PROFILE
add_action( 'show_user_profile', 'extra_profile_fields' );
add_action( 'edit_user_profile', 'extra_profile_fields' );
function extra_profile_fields( $user ) {

    //CHECK FOR AUTHOR BIO CONTENT  
    $check_for_bio = get_the_author_meta('authorbio', $user->ID);
    $author_bio = '';
    if (!empty($check_for_bio)) { $author_bio = $check_for_bio; } 

    //BUILD THE INPUT
    echo '<table class="form-table">';
        echo '<tr>';
            echo '<th><label for="authorbio">Author Biography</label></th>';
            echo '<td>';
            $settings = array('wpautop' => true, 'media_buttons' => false);
            wp_editor( $author_bio, 'authorbio', $settings);        
            echo '</td>';
        echo '</tr>';
    echo '</table>';    
}

//SAVE EXTRA FIELDS TO USER PROFILE
add_action( 'personal_options_update', 'save_extra_profile_fields' );
add_action( 'edit_user_profile_update', 'save_extra_profile_fields' );
function save_extra_profile_fields( $user_id ) {
    if ( !current_user_can( 'edit_user', $user_id ) )
        return false;

    update_user_meta( $user_id, 'authorbio', $_POST['authorbio'] );
}