Description
Filters the email and some of the email settings.
Parameters
$shortcodes
(array) (required) An array of email shortcodes.
$tag
(string) (optional) The email being sent (newreg|newmod|appmod|repass|getuser).
$user_id
(int) (optional) The user ID.
// Default email shortcodes for user emails: $shortcodes = array( 'blogname' => $arr['blogname'], 'username' => $arr['user_login'], 'password' => $password, 'email' => $arr['user_email'], 'reglink' => $arr['reg_link'], 'members-area' => $arr['wpmem_msurl'], 'user-profile' => $arr['wpmem_msurl'], 'exp-type' => $arr['exp_type'], 'exp-data' => $arr['exp_date'], 'exp-date' => $arr['exp_date'], 'login' => $arr['wpmem_login'], 'register' => $arr['wpmem_reg'], ); /* * In addition to the above, any meta keys for fields * in the WP-Members fields tab are included as shortcodes. * For example, if you have a field with a meta_key * of "my_special_field" there will be a shortcode for * [my_special_field] */ // Default email shortcodes for admin notification email: $shortcodes = array( 'blogname' => $arr['blogname'], 'username' => $arr['user_login'], 'email' => $arr['user_email'], 'reglink' => $arr['reg_link'], 'exp-type' => $arr['exp_type'], 'exp-data' => $arr['exp_date'], 'exp-date' => $arr['exp_date'], 'user-ip' => $arr['user_ip'], 'activate-user' => $arr['act_link'], 'fields' => $field_str, ); /* * Custom fields are included in this array, * the same as user emails above. */
Usage
add_filter( 'wpmem_email_shortcodes', function ( $shortcodes, $tag, $user_id ) { // $tag is the email that is being handled. // possible tags are: newreg|newmod|appmod|repass|getuser // This will add a shortcode [my-custom-value] that would be replaced with "Here Is My Value". $shortcodes['my-custom-value'] = "Here Is My Value"; // This is an example of a shortcode replaced with a user meta field (by user ID). $shortcodes['my-user-field-value'] = get_user_meta( $user_id, 'my_user_field', true ); return $shortcodes; }, 10, 3 );
Changelog
- Introduced in version 3.1.0
- 3.4.2 added user ID
Source
wpmem_email_shortcodes
is located in includes/class-wp-members-email.php.