我正在尝试在init
将调用另一个钩子的钩子,如下所示:
add_action( \'init\', \'loadAfterUserRegistrationHook\' );
function loadAfterUserRegistrationHook(){
add_action( \'user_meta_after_user_register\', \'createNewPost\' );
}
function createNewPost( $response ){
global $userMeta;
$userID = $response->ID;
$user = new WP_User( $userID );
$role = $userMeta->getUserRole();
if( $role = \'artiste\' ){
$newPost = array(
\'post_title\' => $user->nickname,
\'post_content\' => $user->description,
\'post_status\' => \'pending\',
\'post_author\' => $userID,
\'post_type\' => \'cpt_artists\'
);
$post_id = wp_insert_post( $newPost );
error_log(\'Post ID : \'.$post_id);
wp_set_object_terms( $post_id, array(\'dj\'), \'artist-category\');
}
}
为什么功能
createNewPost
是否未执行?