アクション xprofile_data_after_save
を拾って、 wp_insert_user()
で更新すればいいと思います。BP_XProfile_Group
クラスのインスタンスが返ってくるので、そこからユーザーIDを取得できると思われます。
【Search Results · GitHub】
https://github.com/dxw/buddypress/search?utf8=%E2%9C%93&q=xprofile_data_after_save
PHP
1// https://github.com/dxw/buddypress/blob/9eb0dbb717a4faeaef534d612b311e7fca7dcbe9/src/bp-xprofile/bp-xprofile-cache.php#L161
2function xprofile_clear_fullname_cache_on_profile_field_edit( $data ) {
3 if ( 1 == $data->field_id ) {
4 wp_cache_delete( 'bp_user_fullname_' . $data->user_id, 'bp' );
5 }
6}
7add_action( 'xprofile_data_after_save', 'xprofile_clear_fullname_cache_on_profile_field_edit' );
【wp_insert_user:WordPress私的マニュアル】
http://elearn.jp/wpman/function/wp_insert_user.html
(参考コード)
【Maps for BuddyPress - Show location of all registered users with cu...】
https://premium.wpmudev.org/forums/topic/maps-for-buddypress-show-location-of-all-registered-users-with-custom-fields#post-156974
PHP
1function my_handler_function ($xprofile) {
2 // ...
3 // Suppose that $my_field_id holds the field ID of the field you wish to check
4 if ($xfield->field_id != $my_field_id) return false;
5 // ...
6
7 // ...
8 // Clear the usermeta cache
9 update_user_meta($xfield->user_id, 'my_usermeta_cache_key', '');
10 // ...
11
12 // Regenerate cache and update the usermeta table
13 // ...
14}
15add_action('xprofile_data_after_save', 'my_handler_function');
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2016/04/05 13:34