admin管理员组文章数量:1122846
I have wroted a function and hooked it to set_user_role action hook. here is my snippet:
add_action( 'set_user_role', 'createTeacherPage', 10, 3);
function createTeacherPage($user_id, $role, $old_roles) {
$postTitle= wp_strip_all_tags(get_userdata($user_id)->data->user_nicename) . ' page';
wp_insert_post(array(
'ID'=> $user_id,
'post_type'=> 'Teacher',
'post_status'=> 'publish',
'post_content'=> '',
'post_title'=> $postTitle
), true);
}
this function creates my custom post_type called teacher once successfully when i changed one of user's role as test. after that I deleted that new Post and I tried again to change user role but the post didn't created anymore. It seems that's related some kind of issues about still existing post or something like that. I will appreciate any idea or guide. thank you.
版权声明:本文标题:wp_insert_post() function doesn't create posts after I deleted the first created Post by this function 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736312275a1935042.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论