Fcrm_Tokens::get_custom_field_value( mixed $key = '', mixed $subscriber_id )

Returns the custom field value.


Parameters Parameters

$key

(Optional) The custom field key.

Default value: ''

$subscriber_id

(Required) The subscriber id.


Top ↑

Return Return

(string) The custom field value. Separated by comma if multiple.


Source Source

File: src/integrations/fluent-crm/tokens/fcrm-tokens.php

	protected function get_custom_field_value( $key = '', $subscriber_id = 0 ) {

		$value = '';

		if ( empty( $key ) ) {
			return $value;
		}

		global $wpdb;

		$value = $wpdb->get_var(
			$wpdb->prepare(
				"SELECT `value` 
                FROM {$wpdb->prefix}fc_subscriber_meta 
                WHERE subscriber_id = %d AND `key` = %s",
				$subscriber_id,
				$key
			)
		);

		if ( is_serialized( $value ) ) {
			$value = maybe_unserialize( $value );
			if ( is_array( $value ) ) {
				$value = implode( ', ', $value );
			}
		}

		return $value;

	}