Ticket #8428: 8428.patch
| File 8428.patch, 5.5 KB (added by , 6 years ago) |
|---|
-
src/bp-core/admin/bp-core-admin-functions.php
diff --git src/bp-core/admin/bp-core-admin-functions.php src/bp-core/admin/bp-core-admin-functions.php index c9a5259e9..51b2eba19 100644
function bp_block_category( $categories = array(), $post = null ) { 1305 1305 ); 1306 1306 } 1307 1307 add_filter( 'block_categories', 'bp_block_category', 1, 2 ); 1308 1309 1310 /** 1311 * Adds a BuddyPress Welcome email after activate user registration. 1312 * 1313 * @since 8.0.0 1314 * 1315 */ 1316 function bp_add_welcome_email() { 1317 // Do not create if it already exists and is not in the trash 1318 $post_exists = post_exists( '[{{{site.name}}}] Welcome!' ); 1319 1320 if ( $post_exists != 0 && get_post_status( $post_exists ) == 'publish' ) 1321 return; 1322 1323 // Create email post object 1324 $my_post = array( 1325 'post_title' => __( '[{{{site.name}}}] Welcome!', 'buddypress' ), 1326 'post_content' => __( 'Welcome to [{{{site.name}}}]!', 'buddypress' ), // HTML email content. 1327 'post_excerpt' => __( 'Welcome to [{{{site.name}}}]!', 'buddypress' ), // Plain text email content. 1328 'post_status' => 'publish', 1329 'post_type' => bp_get_email_post_type() // this is the post type for emails 1330 ); 1331 1332 // Insert the email post into the database 1333 $post_id = wp_insert_post( $my_post ); 1334 1335 if ( $post_id ) { 1336 // add our email to the taxonomy term 'core-user-activation-completed' 1337 // Email is a custom post type, therefore use wp_set_object_terms 1338 1339 $tt_ids = wp_set_object_terms( $post_id, 'core-user-activation-completed', bp_get_email_tax_type() ); 1340 foreach ( $tt_ids as $tt_id ) { 1341 $term = get_term_by( 'term_taxonomy_id', (int) $tt_id, bp_get_email_tax_type() ); 1342 wp_update_term( (int) $term->term_id, bp_get_email_tax_type(), array( 1343 'description' => 'Recipient has successfully activated an account.', 1344 ) ); 1345 } 1346 } 1347 } 1348 add_action( 'bp_core_install_emails', 'bp_add_welcome_email' ); 1349 -
src/bp-core/bp-core-functions.php
diff --git src/bp-core/bp-core-functions.php src/bp-core/bp-core-functions.php index 592f5b155..25b0fd4e7 100644
function bp_email_get_schema() { 3684 3684 * @param array $emails The array of emails schema. 3685 3685 */ 3686 3686 return (array) apply_filters( 'bp_email_get_schema', array( 3687 'core-user-activation-completed' => array( 3688 /* translators: do not remove {} brackets or translate its contents. */ 3689 'post_title' => __( '[{{{site.name}}}] Welcome!', 'buddypress' ), 3690 /* translators: do not remove {} brackets or translate its contents. */ 3691 'post_content' => __( 'Welcome to [{{{site.name}}}]!', 'buddypress' ), 3692 /* translators: do not remove {} brackets or translate its contents. */ 3693 'post_excerpt' => __( 'Welcome to [{{{site.name}}}]!', 'buddypress' ), 3694 ), 3687 3695 'activity-comment' => array( 3688 3696 /* translators: do not remove {} brackets or translate its contents. */ 3689 3697 'post_title' => __( '[{{{site.name}}}] {{poster.name}} replied to one of your updates', 'buddypress' ), … … function bp_email_get_schema() { 3814 3822 'post_content' => __( "Your membership request for the group "<a href=\"{{{group.url}}}\">{{group.name}}</a>" has been rejected.", 'buddypress' ), 3815 3823 /* translators: do not remove {} brackets or translate its contents. */ 3816 3824 'post_excerpt' => __( "Your membership request for the group \"{{group.name}}\" has been rejected.\n\nTo request membership again, visit: {{{group.url}}}", 'buddypress' ), 3817 ), 3825 ), 3818 3826 ) ); 3819 3827 } 3820 3828 … … function bp_email_get_type_schema( $field = 'description' ) { 3955 3963 'message' => __( 'You will no longer receive emails when your request to join a group has been accepted or denied.', 'buddypress' ), 3956 3964 ), 3957 3965 ); 3966 3967 $core_user_activation_completed = array( 3968 'description' => __( 'Recipient has successfully activated an account.', 'buddypress' ), 3969 ); 3958 3970 3959 3971 $types = array( 3960 3972 'activity-comment' => $activity_comment, … … function bp_email_get_type_schema( $field = 'description' ) { 3973 3985 'settings-verify-email-change' => $settings_verify_email_change, 3974 3986 'groups-membership-request-accepted' => $groups_membership_request_accepted, 3975 3987 'groups-membership-request-rejected' => $groups_membership_request_rejected, 3988 'core-user-activation-completed' => $core_user_activation_completed, 3976 3989 ); 3977 3990 3978 3991 if ( $field !== 'all' ) { -
src/bp-members/bp-members-functions.php
diff --git src/bp-members/bp-members-functions.php src/bp-members/bp-members-functions.php index 165bc97c3..3c89efb28 100644
function bp_members_avatar_upload_dir( $directory = 'avatars', $user_id = 0 ) { 3306 3306 'error' => false 3307 3307 ) ); 3308 3308 } 3309 3310 3311 /** 3312 * Send Core user welcome email on user activation link 3313 * 3314 * @since 8.0.0 3315 * 3316 * @param int $user_id The user ID 3317 */ 3318 3319 function bp_send_welcome_email( $user_id ){ 3320 // add tokens to parse in email 3321 $args = array( 3322 'tokens' => array( 3323 ), 3324 ); 3325 3326 // add each xprofile field value of the user as an available token (e.g. {{xprofile.1}} for the field_id of "1") 3327 $xprofile_field_ids = bp_xprofile_get_fields_by_visibility_levels( $user_id, array( 'public', 'friends', 'loggedin', 'adminsonly' ) ); 3328 foreach( $xprofile_field_ids as $field_id ) { 3329 $token_key = 'xprofile.' . $field_id; 3330 $args['tokens'][$token_key] = xprofile_get_field_data( $field_id, $user_id ); 3331 } 3332 3333 // send args and user ID to receive email 3334 bp_send_email( 'core-user-activation-completed', $user_id, $args ); 3335 3336 } 3337 add_action( 'bp_core_activated_user', 'bp_send_welcome_email' ); 3338 No newline at end of file