Identical to do_replacements() but processes merge tags in plain-text context so HTML entities are not escaped. Use this for plain-text outputs such as SMS bodies, webhook payloads, or CLI output.
Parameters
| Parameter | Type | Description |
|---|---|---|
$content | string | The string containing merge tags to process. |
$contact_id | int|Contact | The contact for replacements. |
Return value
string — The content with merge tags replaced in plain-text context.
Usage
$body = 'Hi {first_name}! Your appointment is on {meta.appointment_date}.';
$message = \Groundhogg\do_replacements_plain_text( $body, $contact );
Example
Here’s a pseudo code example for a hypothetical webhook payload integration.
add_action( 'groundhogg/contact/created', 'my_plugin_post_contact_to_webhook' );
/**
* Send a personalised payload to a webhook when a contact is created.
*
* @param \Groundhogg\Contact $contact
*
* @return void
*/
function my_plugin_post_contact_to_webhook( $contact ) {
$template = get_option( 'my_plugin_webhook_note', 'New contact: {full_name} ({email})' );
wp_remote_post( MY_PLUGIN_WEBHOOK_URL, [
'body' => [
'message' => \Groundhogg\do_replacements_plain_text( $template, $contact ),
'contact_id' => $contact->get_id(),
],
] );
}
Was this helpful?
Let us know if this document answered your question. That’s the only way we can improve.
