Limit user description length in characters

How can I limit character length of user description field? I want to restrict users within 250 characters. I've ad

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!

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745345233a4623512.html

相关推荐

  • Limit user description length in characters

    How can I limit character length of user description field? I want to restrict users within 250 characters. I've ad

    5小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信