I am building a custom biography field in the wordpress user profile page using WP's wp_editor api (using WP version 3.3.1).
When I add any content though, the WSYIWYG editor is not writing the paragraph tags to the database.
I am able to use the visual editor to add all other mark-up (bold, italics, etc) & I can manually add paragraph tags and save the full marked-up text to the database.
Has anyone else run into this issue? Code I'm using to build the custom field in the functions.php file below.
//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'] );
}
Solved the issue. Was not adding the_content fitler. When printing the output.
<?php
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
?>
http://codex.wordpress.org/Function_Reference/the_content
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With