Creating new email Tags
-
Hello! I’m trying to setup two new email tags and failing to do it. Actually, the tags are created already, but the function it outputs is coming up empty.
One tag is to display in the admin email a custom field called “Company” that the user must fill when is registering (this is already created and saved in the DB as a user meta field). The other is a simpler tag that will display the Users full name (First Name + Last Name).
Can anyone help me with the function to output it? I’m confused especially with the$attributes
parameter.Here is the code I have:
<?php /** * Add a new email tag * $tags an array of the current email tags */ function add_email_tag($email_tags) { $email_tags[] = array( 'tag' => 'user_company', 'description' => __( 'The user Company' ), 'function' => 'company_email_tag', 'context' => array( 'email' ), ); $email_tags[] = array( 'tag' => 'user_fullname', 'description' => __( 'The user First and Last name' ), 'function' => 'fullname_email_tag', 'context' => array( 'email' ), ); return $email_tags; } add_filter( 'nua_email_tags', 'add_email_tag', 5); /** * Now when I add '{user_company}' to an email template, that text will be * replaced by using the function below. */ function company_email_tag( $attributes ) { return $attributes['company']; } function fullname_email_tag() { return esc_attr( $user->first_name ) . esc_attr( $user->last_name ); }
I also tried:
function company_email_tag( $attributes ) { $current_user = wp_get_current_user(); $company = get_user_meta( $current_user->ID, 'company', true ); return $company; }
But no success on the email (it works on a normal page when echoing this function).
Thanks!
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
- The topic ‘Creating new email Tags’ is closed to new replies.