User Post Type – change post_name

mgibbs189

{{gist file=”functions.php” lang=”php”}}
<?php

// Add to your (child) theme’s functions.php

add_filter( ‘wp_insert_post_data’, function( $data ) {
if ( ‘upt_user’ == $data[‘post_type’] ) {
$user_id = (int) $data[‘post_author’];
$user_data = get_userdata( $user_id );
$slug = $user_data->first_name . ‘-‘ . $user_data->last_name . ‘-‘ . $user_id;
$data[‘post_name’] = sanitize_title( $slug );
}
return $data;
});
{{/gist}}