Code for unsubscribe
-
I’m customizing the code and I want to give an extra option to the subscriber, what code do I put here?

-
Where I put this code?
function bitly_keyword( $string, $token = 'PUT YOUR API TOKEN HERE') { global $mysubscribe2; $link = $mysubscribe2->get_tracking_link( $mysubscribe2->permalink ); $bitlydata = wp_remote_get('https://api-ssl.bitly.com/v3/shorten?access_token=' . $token . '&longUrl=' . urlencode($link)); $data = json_decode( wp_remote_retrieve_body( $bitlydata ) ); if ( 'ok' === strtolower($data->status_txt) && 200 === (int)$data->status_code ) { $bitlylink = '<a>data->url . '">' . $data->data->url . '</a>'; } else { $bitlylink = '<a href="' . $link . '">' . $link . '</a>'; } return str_replace('{BITLYLINK}', $bitlylink, $string); } add_filter('s2_custom_keywords', 'bitly_keyword');I think you can put a default code like {unsubscribe}
Either in your themes functions.php file or better still create your own custom site plugin to ensure your changes won’t be lost if the Theme is updated.
If you’ve never created a plugin before use Pluginception – it sets things up niceley for you to just add the code.
Ok. I put this in functions.php file child, then what I do?
function bitly_keyword( $string, $token = 'PUT YOUR API TOKEN HERE') { global $mysubscribe2; $link = $mysubscribe2->get_tracking_link( $mysubscribe2->permalink ); $bitlydata = wp_remote_get('https://api-ssl.bitly.com/v3/shorten?access_token=' . $token . '&longUrl=' . urlencode($link)); $data = json_decode( wp_remote_retrieve_body( $bitlydata ) ); if ( 'ok' === strtolower($data->status_txt) && 200 === (int)$data->status_code ) { $bitlylink = '<a>data->url . '">' . $data->data->url . '</a>'; } else { $bitlylink = '<a href="' . $link . '">' . $link . '</a>'; } return str_replace('{BITLYLINK}', $bitlylink, $string); } add_filter('s2_custom_keywords', 'bitly_keyword');That code specifically allows you to use a {BITLYLINK} keyword in the body of the email notification to include links to your posts that have been shortened using the Bit.ly URL shortener.
You would need to create some code the implements the additional functionality your briefly described in your original post.
Ok, maybe I didn’t explain myself: I need a code that the user clicks and cancels his registration.
Eg: “If you want to cancel your subscription click here: {code}”That feature is available in Subscribe2 HTML as an extra feature.
If you want to create this yourself you’d need to create code using the snippet example above to create a keyword that inserts a link into the email notification that is unique for each email recipient.
After that is done and working you’d need to handle users clicking on those links and process the request on your site with a bit more code linking into the Subscribe2 unsubscribe functions.
I’m not able to do it. You could put it in the next version.
The topic ‘Code for unsubscribe’ is closed to new replies.