• Resolved steve92

    (@steve92)


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

Viewing 8 replies - 1 through 8 (of 8 total)
  • @steve92

    That’s not code, that’s an email template. You can’t put code in there but you can use the existing keywords listed on the right or create your own {CUSTOM_KEYWORD} using the plugin ‘s2_custom_keywords’ hook as documented here.

    Thread Starter steve92

    (@steve92)

    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}

    @steve92

    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.

    Thread Starter steve92

    (@steve92)

    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');

    @steve92

    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.

    Thread Starter steve92

    (@steve92)

    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}”

    @steve92

    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.

    Thread Starter steve92

    (@steve92)

    I’m not able to do it. You could put it in the next version.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Code for unsubscribe’ is closed to new replies.