Shortcodes & WP Custom Profile Fields
-
Hi, I created some WP Custom Profile Fields with:
function campos_de_perfil( $user_contact_method ) { $user_contact_method['dni'] = __( 'DNI', 'campos_de_perfil' ); return $user_contact_method; } add_filter( 'user_contactmethods', 'campos_de_perfil' );All works perfectly here and I can enter a value to “dni”.
After that, I want Mailpoet to return that custom value into the newsletter via a shortcode. I have done the shortcode like that:
//MAILPOET CUSTOM SHORTCODES function mailpoet_shortcodes_custom_filter( $tag_value , $user_id ) { if ($tag_value === 'dni') { // get the wpuser_id of that subscriber $model_user = WYSIJA::get('user','model'); $subscriber_data = (array)$model_user->getOne(array( 'wpuser_id' ) , array( 'user_id' => $user_id)); // get the wp-user data based on the wp-user id $wpuser_data = get_userdata( $subscriber_data['wpuser_id'] ); // return the key you want $replacement = $wpuser_data->dni; } return $replacement; } // filter registration allowing the two parameters $tag_value and $user_id to be passed add_filter('wysija_shortcodes', 'mailpoet_shortcodes_custom_filter', 10 , 2);After that, I created a newsletter with the shortcode:
[user:dni]or[dni]And I’ve sent me a test email and the value doesn’t appear… What I did wrong?
Thanks!
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
The topic ‘Shortcodes & WP Custom Profile Fields’ is closed to new replies.