get_noptin_subscriber_merge_fields( int $subscriber_id )

Retrieve subscriber merge fields.


Parameters Parameters

$subscriber_id

(int) (Required) Subscriber ID.


Top ↑

Source Source

File: includes/subscriber.php

function get_noptin_subscriber_merge_fields( $subscriber_id ) {
	$subscriber = get_noptin_subscriber( $subscriber_id );

	if ( ! $subscriber->exists() ) {
		return array();
	}

	$merge_tags                    = $subscriber->to_array();
	$merge_tags['unsubscribe_url'] = get_noptin_action_url( 'unsubscribe', $subscriber->confirm_key );
	$meta                          = $subscriber->get_meta();

	foreach ( $meta as $key => $values ) {

		if ( isset( $values[0] ) && is_scalar( maybe_unserialize( $values[0] ) ) ) {
				$merge_tags[ $key ] = esc_html( maybe_unserialize( $values[0] ) );
		}
	}

	$merge_tags['name']      = trim( $merge_tags['first_name'] . ' ' . $merge_tags['second_name'] );
	$merge_tags['last_name'] = $merge_tags['second_name'];

	return apply_filters( 'noptin_subscriber_merge_fields', $merge_tags, $subscriber, $meta );
}


Top ↑

Changelog Changelog

Changelog
VersionDescription
1.2.0Introduced.

Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation