groundhogg/unsubscribe_url

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Filter Hooks

Β»

groundhogg/unsubscribe_url

Filters the unsubscribe URL generated for a contact. Use this to redirect unsubscribes through a custom preferences page.

apply_filters( 'groundhogg/unsubscribe_url', $url, $contact );

You will receive the generated URL string and the Contact object.

Example

add_filter( 'groundhogg/unsubscribe_url', 'my_extension_custom_unsub_url', 10, 2 );

/**
 * Send contacts to a custom unsubscribe page.
 *
 * @param string               $url
 * @param \Groundhogg\Contact $contact
 *
 * @return string
 */
function my_extension_custom_unsub_url( $url, $contact ) {
    return add_query_arg( [
        'email' => urlencode( $contact->get_email() ),
        'token' => my_extension_generate_token( $contact ),
    ], home_url( '/email-preferences/' ) );
}

Was this helpful?

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