Wordpress backend textarea adding and saving


Staff member
I'm trying to move from simple text input to textarea, but really don't know how to put value afterward into it. I dont code, but i tried really hard for few hours to edit this code

following this man: <a href="https://www.cssigniter.com/how-to-add-a-custom-user-field-in-wordpress/" rel="nofollow noreferrer">https://www.cssigniter.com/how-to-add-a-custom-user-field-in-wordpress/</a> but really messed it up. My goal is to have a textarea with multiple lines saved as WordPress user meta and also displayed in backend. This user meta to the database now doesn't work and is not displaying in backend.

add_action( 'show_user_profile', 'crf_show_extra_profile_fields' );
add_action( 'edit_user_profile', 'crf_show_extra_profile_fields' );

function crf_show_extra_profile_fields( $user ) {
    $added_books = get_the_author_meta( 'added_books', $user-&gt;ID );

    &lt;table class="form-table"&gt;
            &lt;th&gt;&lt;label for="added_books"&gt;&lt;?php esc_html_e( 'Added books: ', 'crf' ); ?&gt;&lt;/label&gt;&lt;/th&gt;
            &lt;textarea id="added_books" name="added_books" &gt;&lt;?php echo ( $added_books ); ?&gt;&lt;/textarea&gt;

add_action( 'personal_options_update', 'crf_update_profile_fields' );
add_action( 'edit_user_profile_update', 'crf_update_profile_fields' );

function crf_update_profile_fields( $user_id ) {
    if ( ! current_user_can( 'edit_user', $user_id ) ) {
        return false;

    if ( ! empty( $_POST['added_books'] ) &amp;&amp; sanitize_textarea_field( $_POST['added_books'] ) ) {
        update_user_meta( $user_id, 'added_books', sanitize_textarea_field( $_POST['added_books'] ) );