回答編集履歴

1

追記

2017/12/05 05:26

投稿

退会済みユーザー
test CHANGED
@@ -37,3 +37,51 @@
37
37
  plain_password
38
38
 
39
39
  ```
40
+
41
+
42
+
43
+ コード的にはこんな感じでいけると思います。
44
+
45
+ メールアドレスは必須だと思うので、それを元にユーザーIDを取得しています。
46
+
47
+ 姓名はアドオンを使わないと必須に出来ないと思うので、必須でなければ空欄で登録された場合の対処も必要かと思います。
48
+
49
+ 姓名をどのように使うのか分からない為、適当ですが参考にしてみてください。
50
+
51
+
52
+
53
+ ```
54
+
55
+ function auto_post( $member_info ) {
56
+
57
+ $email = get_user_by( 'email', $member_info['email'] );
58
+
59
+ if( !isset( $member_info['first_name'] ) ) {
60
+
61
+ $member_info['first_name'] = '名無し'; // first_nameが空白の場合
62
+
63
+ }
64
+
65
+ if( !isset( $member_info['last_name'] ) ) {
66
+
67
+ $member_info['last_name'] = '774'; // last_nameが空白の場合
68
+
69
+ }
70
+
71
+ $my_post = array();
72
+
73
+ $my_post['post_title'] = $member_info['first_name'];
74
+
75
+ $my_post['post_content'] = $member_info['last_name'];
76
+
77
+ $my_post['post_status'] = 'draft';
78
+
79
+ $my_post['post_author'] = $email->ID;
80
+
81
+ $post_id = wp_insert_post( $my_post );
82
+
83
+ }
84
+
85
+ add_action( 'swpm_front_end_registration_complete_user_data', 'auto_post' );
86
+
87
+ ```