admin管理员组

文章数量:1420907

How can I limit character length of user description field? I want to restrict users within 250 characters. I've added the code to solve this-

add_filter( 'pre_user_description', 'limit_user_bio_character_length');
function limit_user_bio_character_length() {
    $current_user = wp_get_current_user(); get_currentuserinfo();
    $description = get_user_meta($current_user->ID, 'description', true);
    if ( strlen(( $description )) > 250 ) {
        update_user_meta($current_user->ID, 'description', substr($description, 0, 250));
    }
}

This code not working, after update user bio disappears!

本文标签: Limit user description length in characters