From 9bd85f8e4d081b00d9f72e4a5422c7eecd541864 Mon Sep 17 00:00:00 2001 From: ryan Date: Fri, 26 May 2006 22:49:31 +0000 Subject: [PATCH] Add some user filters. git-svn-id: http://svn.automattic.com/wordpress/branches/2.0@3802 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/admin-db.php | 4 ++-- wp-includes/default-filters.php | 27 ++++++++++++++++++++++++ wp-includes/registration-functions.php | 29 ++++++++++++++++++++++++-- 3 files changed, 56 insertions(+), 4 deletions(-) diff --git a/wp-admin/admin-db.php b/wp-admin/admin-db.php index 6333797bc0..89732b8700 100644 --- a/wp-admin/admin-db.php +++ b/wp-admin/admin-db.php @@ -93,16 +93,16 @@ function wp_insert_category($catarr) { $update = false; $cat_name = apply_filters('pre_category_name', $cat_name); - $category_nicename = apply_filters('pre_category_nicename', $category_nicename); - $category_description = apply_filters('pre_category_description', $category_description); if (empty ($category_nicename)) $category_nicename = sanitize_title($cat_name); else $category_nicename = sanitize_title($category_nicename); + $category_nicename = apply_filters('pre_category_nicename', $category_nicename); if (empty ($category_description)) $category_description = ''; + $category_description = apply_filters('pre_category_description', $category_description); $category_parent = (int) $category_parent; if (empty ($category_parent)) diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php index 4795b532ec..26116e009b 100644 --- a/wp-includes/default-filters.php +++ b/wp-includes/default-filters.php @@ -56,6 +56,33 @@ add_filter('pre_category_name', 'wp_filter_kses'); add_filter('pre_category_name', 'wp_specialchars', 30); add_filter('pre_category_description', 'wp_filter_kses'); +// Users +add_filter('pre_user_display_name', 'strip_tags'); +add_filter('pre_user_display_name', 'trim'); +add_filter('pre_user_display_name', 'wp_filter_kses'); +add_filter('pre_user_display_name', 'wp_specialchars', 30); +add_filter('pre_user_first_name', 'strip_tags'); +add_filter('pre_user_first_name', 'trim'); +add_filter('pre_user_first_name', 'wp_filter_kses'); +add_filter('pre_user_first_name', 'wp_specialchars', 30); +add_filter('pre_user_last_name', 'strip_tags'); +add_filter('pre_user_last_name', 'trim'); +add_filter('pre_user_last_name', 'wp_filter_kses'); +add_filter('pre_user_last_name', 'wp_specialchars', 30); +add_filter('pre_user_nickname', 'strip_tags'); +add_filter('pre_user_nickname', 'trim'); +add_filter('pre_user_nickname', 'wp_filter_kses'); +add_filter('pre_user_nickname', 'wp_specialchars', 30); +add_filter('pre_user_description', 'strip_tags'); +add_filter('pre_user_description', 'trim'); +add_filter('pre_user_description', 'wp_filter_kses'); +add_filter('pre_user_description', 'wp_specialchars', 30); +add_filter('pre_user_url', 'strip_tags'); +add_filter('pre_user_url', 'trim'); +add_filter('pre_user_url', 'clean_url'); +add_filter('pre_user_email', 'trim'); +add_filter('pre_user_email', 'sanitize_email'); + // Places to balance tags on input add_filter('content_save_pre', 'balanceTags', 50); add_filter('excerpt_save_pre', 'balanceTags', 50); diff --git a/wp-includes/registration-functions.php b/wp-includes/registration-functions.php index 41f479769f..dcf81f5093 100644 --- a/wp-includes/registration-functions.php +++ b/wp-includes/registration-functions.php @@ -27,6 +27,7 @@ function wp_insert_user($userdata) { // Are we updating or creating? if ( !empty($ID) ) { + $ID = (int) $ID; $update = true; } else { $update = false; @@ -35,16 +36,40 @@ function wp_insert_user($userdata) { } $user_login = sanitize_user($user_login, true); + $user_login = apply_filters('pre_user_login', $user_login); if ( empty($user_nicename) ) $user_nicename = sanitize_title( $user_login ); + $user_nicename = apply_filters('pre_user_nicename', $user_nicename); + + if ( empty($user_url) ) + $user_url = ''; + $user_url = apply_filters('pre_user_url', $user_url); + + if ( empty($user_email) ) + $user_email = ''; + $user_email = apply_filters('pre_user_email', $user_email); if ( empty($display_name) ) $display_name = $user_login; - + $display_name = apply_filters('pre_user_display_name', $display_name); + if ( empty($nickname) ) $nickname = $user_login; - + $nickname = apply_filters('pre_user_nickname', $nickname); + + if ( empty($first_name) ) + $first_name = ''; + $first_name = apply_filters('pre_user_first_name', $first_name); + + if ( empty($last_name) ) + $last_name = ''; + $last_name = apply_filters('pre_user_last_name', $last_name); + + if ( empty($description) ) + $description = ''; + $description = apply_filters('pre_user_description', $description); + if ( empty($user_registered) ) $user_registered = gmdate('Y-m-d H:i:s');