unsubscribe_url

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Functions

Β»

unsubscribe_url

Generates a personalised unsubscribe URL for a contact. Depending on whether one-click unsubscribe is enabled in Groundhogg settings, this links either directly to the immediate unsubscribe page or to the preferences management page. The URL includes a permissions key so the contact is automatically identified when they click through. Filterable via groundhogg/unsubscribe_url.

Parameters

ParameterTypeDescription
$contactContactThe contact to generate the unsubscribe URL for.

Return value

string β€” The full unsubscribe URL with permissions key.

Usage

$url = \Groundhogg\unsubscribe_url( $contact );

echo 'Unsubscribe';

Example

Here’s a pseudo code example for a hypothetical custom email footer integration.

add_filter( 'groundhogg/email_template/footer_text', 'my_plugin_custom_footer_text' );

/**
 * Replace the default footer text with a custom unsubscribe line.
 *
 * @param string $text
 *
 * @return string
 */
function my_plugin_custom_footer_text( $text ) {

    $contact = \Groundhogg\get_current_contact();

    if ( ! $contact ) {
        return $text;
    }

    $url = \Groundhogg\unsubscribe_url( $contact );

    return 'You received this because you signed up at example.com. '
        . 'Unsubscribe at any time.';
}

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.