質問するログイン新規登録

回答編集履歴

1

追記

2017/12/05 05:26

投稿

退会済みユーザー
answer CHANGED
@@ -17,4 +17,28 @@
17
17
  account_state
18
18
  membership_level
19
19
  plain_password
20
+ ```
21
+
22
+ コード的にはこんな感じでいけると思います。
23
+ メールアドレスは必須だと思うので、それを元にユーザーIDを取得しています。
24
+ 姓名はアドオンを使わないと必須に出来ないと思うので、必須でなければ空欄で登録された場合の対処も必要かと思います。
25
+ 姓名をどのように使うのか分からない為、適当ですが参考にしてみてください。
26
+
27
+ ```
28
+ function auto_post( $member_info ) {
29
+ $email = get_user_by( 'email', $member_info['email'] );
30
+ if( !isset( $member_info['first_name'] ) ) {
31
+ $member_info['first_name'] = '名無し'; // first_nameが空白の場合
32
+ }
33
+ if( !isset( $member_info['last_name'] ) ) {
34
+ $member_info['last_name'] = '774'; // last_nameが空白の場合
35
+ }
36
+ $my_post = array();
37
+ $my_post['post_title'] = $member_info['first_name'];
38
+ $my_post['post_content'] = $member_info['last_name'];
39
+ $my_post['post_status'] = 'draft';
40
+ $my_post['post_author'] = $email->ID;
41
+ $post_id = wp_insert_post( $my_post );
42
+ }
43
+ add_action( 'swpm_front_end_registration_complete_user_data', 'auto_post' );
20
44
  ```