0
작성자 자격 증명 이상의 사용자별로 사용자 정의 게시물 유형 (jt_cpt_team
)의 게시물을 자동으로 만들려고합니다.wp_insert_post를 사용하여 각 사용자의 게시물을 자동으로 만듭니다.
주로 관리자가 만든 새 사용자마다이 작업을 수행해야합니다. 각 기존 작성자 (~ 30)에 대한 게시물을 생성하는 쉬운 방법이 있다면 훌륭한 방법이지만 필요한 경우 직접 작성하는 것은 신경 쓰지 않아도됩니다.
나는 이것이 더 많거나 적다는 것을 짐작하고있다. — & hellip;
class team_functions {
public function __construct() {
add_action('user_register', array($this, 'create_authors_page'));
}
public function create_authors_page($user_id) {
$the_user = get_userdata($user_id);
$new_user_name = $the_user->user_login;
$my_post = array();
$my_post['post_title'] = $new_user_name;
$my_post['post_type'] = 'jt_cpt_team';
$my_post['post_content'] = '';
$my_post['post_status'] = 'publish';
$my_post['post_theme'] = 'user-profile';
wp_insert_post($my_post);
}
}
또한, 최고 일 것 custom_field
으로 저자의 이메일을 추가 할 수있는 방법이 있다면. 모든 도움에 미리
감사합니다 :)이 같은
는 - 마법처럼 작동합니다! :) 고맙습니다. – richerimage
다른 하나는 Authors ID로 'custom_field'를 채우고 싶습니다.이 함수 내에서 가능합니까? 감사. – richerimage
@richerimage 답변을 업데이트했습니다. –