Skip to content

Instantly share code, notes, and snippets.

@X-Raym
Last active November 22, 2016 10:37
Show Gist options
  • Select an option

  • Save X-Raym/0c32f13bb2d2990326bc48f550899b3a to your computer and use it in GitHub Desktop.

Select an option

Save X-Raym/0c32f13bb2d2990326bc48f550899b3a to your computer and use it in GitHub Desktop.
Set all WP users name to regular case
<?php
// Place this in Home directory
define( 'WP_USE_THEMES', false );
require( 'wp-blog-header.php' );
// Security Check
if ( current_user_can( 'manage_options' ) === false )
wp_die();
$users = get_users();
foreach ($users as $user) {
$first_name = get_user_meta( $user->ID, 'first_name', true );
$last_name = get_user_meta( $user->ID, 'last_name', true );
$first_name_new = mb_convert_case($first_name, MB_CASE_TITLE, "UTF-8");
$last_name_new = mb_convert_case($last_name, MB_CASE_TITLE, "UTF-8");
echo '<p>' . $last_name . ' ' . $first_name . '<br/>';
echo $last_name_new . ' ' . $first_name_new . '</p>';
// Append '?update' to the url to perform changes
if ( isset( $_GET["update"] ) ) {
update_user_meta( $user->ID, 'first_name', $first_name_new );
update_user_meta( $user->ID, 'last_name', $last_name_new );
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment