Example #1
0
/**
 * Confirms a subscription identified by id and token, changing it's status on
 * database. Fill the global $newsletter_subscriber with user data.
 * If the subscription id already confirmed, the welcome email is still sent to
 * the subscriber (the welcome email can contains somthing reserved to the user
 * and he may has lost it).
 * If id and token do not match, the function does nothing.
 */
function newsletter_confirm($id, $token)
{
    global $wpdb, $newsletter_subscriber;
    $options = get_option('newsletter');
    $newsletter_subscriber = newsletter_get_subscriber($id);
    newsletter_info(__FUNCTION__, "Starting confirmation of subscriber " . $id);
    if ($newsletter_subscriber == null) {
        newsletter_error(__FUNCTION__, "Subscriber not found");
        return;
    }
    if ($newsletter_subscriber->token != $token) {
        newsletter_error(__FUNCTION__, "Token not matching");
        return;
    }
    newsletter_debug(__FUNCTION__, "Confirming subscriber:\n" . print_r($newsletter_subscriber, true));
    $count = $wpdb->query($wpdb->prepare("update " . $wpdb->prefix . "newsletter set status='C' where id=%d", $id));
    newsletter_send_welcome($newsletter_subscriber);
}
Example #2
0
_e('Order', 'newsletter');
?>
</th>
                    <td>
                        <select name="order">
                            <option value="id">id</option>
                            <option value="email">email</option>
                        </select>
                    </td>
                </tr>
            </table>
        </div>

        <?php 
if ($_POST['a'] == 'edit' && check_admin_referer()) {
    $subscriber = newsletter_get_subscriber($_POST['id']);
    ?>
        <input type="hidden" name="subscriber[id]" value="<?php 
    echo $subscriber->id;
    ?>
"/>
        <table class="form-table">
            <tr valign="top">
                <th>Name</th>
                <td><input type="text" name="subscriber[name]" size="40" value="<?php 
    echo htmlspecialchars($subscriber->name);
    ?>
"/></td>
            </tr>
            <tr valign="top">
                <th>Email</th>
Example #3
0
function newsletter_get_subscriber_strict($id, $token)
{
    if (is_null($token)) {
        newsletter_fatal(__FUNCTION__, 'Ivalid token');
        return null;
    }
    $s = newsletter_get_subscriber($id, $token);
    if (is_null($s)) {
        newsletter_fatal(__FUNCTION__, 'Subscriber not found or invalid token');
    }
    return $s;
}