Created by cutiko 2015-10-01 View revision File functions.php Added Side-by-side diff More Ignore whitespace Hide word diff +<?php +/*This will create a post with the user name when the user is created*/ +add_action( 'user_register', 'new_user_insert_janitor_post', 999); + +function new_user_insert_janitor_post($user_id) { + + // The $user variable for getting the user + $user = get_user_by('id', $user_id); + + if( is_array( $user->roles ) ) { + if( in_array( 'administrator', $user->roles ) ) { + //Do nothing + } else { + $array = array( + 'post_type' => 'janitor', + 'post_title' => $user->nickname, + 'post_status' => 'publish', + 'post_author' => 1 + ); + wp_insert_post( $array ); + } + } + +} +?>