• Resolved pkl

    (@pkl)


    I have a *very* basic understanding of PhP and need to combine subscription to a newsletter with subscription to new posts. Users already use a newsletter plugin to subscribe to the newsletter. How would I send the user’s email address *from* the newsletter plugin *to* this plugin, so the email is also added to the post subscriptions? I assume a simple code segment is all that’s needed, but I don’t know enough to figure it out on my own. (I am learning…!)

    http://wordpress.org/plugins/subscribe2/

Viewing 13 replies - 1 through 13 (of 13 total)
  • @pkl,

    Without knowing what newsletter plugin you are using and how the subscriber email addresses are stored it’s impossible to know how this can be achieved.

    Within Subscribe2 you can import a list of existing email addresses. That would leave the 2 plugins operating independently with subscribers details stored in both systems. That approach would mean 2 emails for your subscribers though, 1 for new posts and 1 for your newsletter.

    Thread Starter pkl

    (@pkl)

    Thanks. This is the code that asks users to submit their email to subscribe to the newsletter. Is there a way to send the same email address to subscribe2 as well?

    The other option would be to use subscribe2 as the plugin that asks for the email, and then add some code there to also submit the email address to vertical response.

    <form method="post" action="http://oi.vresp.com?fid=62c0b66827" target="vr_optin_popup" onsubmit="window.open( 'http://www.verticalresponse.com', 'vr_optin_popup', 'scrollbars=yes,width=600,height=450' ); return true;" >
    
      <div style="font-family: verdana; font-size: 11px; width: 110px; padding: 7px; margin: 0 12px; border: 1px solid #8D8368; background: #8D8368">
        <strong><span style="color: #ffffff;">Sign Up For Leslie Davenport's Newsletter</span></strong><br/><br/>
        <label style="color: #ffffff;">Email Address:</label><br/>
        <input name="email_address" size="12" style="margin-top: 5px; border: 1px solid #999; padding: 3px;"/><br/>
        <input type="submit" value="Subscribe" style="margin-top: 5px; border: 1px solid #999; padding: 3px;"/><br/>
      </div>
    </form>
            <br />
    
            <div style="width: 120px; margin: 0 12px;">
            <form name="eMailer">

    @pkl,

    That form you’ve posted sends the data directly to the Virtual Response server and access the API to add the subscriber details to your list.

    In order to achieve what you want it would need a totally new form that collects the data and processes it on your server adding the subscriber email address to both subscribe2 and Virtual Response.

    The other option is to see if you can find a plugin that pushes your post content into the Virtual Response server to generated a newsletter when you publish.

    Thread Starter pkl

    (@pkl)

    “In order to achieve what you want it would need a totally new form that collects the data and processes it on your server adding the subscriber email address to both subscribe2 and Virtual Response.”

    Yes, I think I can do that. Can you let me know how to add the subscriber email address to subscribe2? I assume it would be just one line of code? Thanks!

    @pkl,

    It’s a bit more complicated than just one line!

    I’m presuming you have sanitised the email correctly first, after that this code should do the trick:

    global $mysubscribe2;
    $mysubscribe2->email = $email;
    if ( '1' !== $mysubscribe2->is_public($mysubscribe2->email) ) {
    	$mysubscribe2->add($this->email);
    	$status = $mysubscribe2->send_confirm('add');
    }

    Thread Starter pkl

    (@pkl)

    Thank you, I appreciate it very much. I will give it a go.

    @pkl,

    Your welcome. Let me know how it goes. (Of course it might be worth using the same code in a similar way to allow unsubscriptions too).

    Well what I am doing is when the submit button for the newsletter form is clicked, I am calling a javascript function to collect the email address from the form.

    Then I am loading the index page again sending the email as get request. Since the newsletter form loads in a new popup window, it wont affect the form at all.

    I am then using the code provided by you in the template. But neither I am seeing any error message, but the site stops loading at that same point where I have used the code.

    @prakashchhetri,

    When you reload the page you’ll possibly lose the form input so you’d need to collect that from the $_GET variable to pass into the code above.

    Yea I collected the $_GET variable

    $email = strip_tags(trim($_GET['email']));
    		global $mysubscribe2;
    		$mysubscribe2->email = $email;
    		if ( '1' !== $mysubscribe2->is_public($mysubscribe2->email) ) {
    			$mysubscribe2->add($this->email);
    			$status = $mysubscribe2->send_confirm('add');
    		}

    But when the page loads with the $_GET value, and when the execution reaches the line where I have added the code, the execution stops there and the rest of the page is blank.
    I dont even see any error messages.

    @prakashchhetri,

    Is that code wrapped in PHP markers then? Is it being recognised as PHP?

    Yea, the code is wrapped inside if statement, where I am checking for valid get request.

    And then the code should only be executed for a valid get request. I tested the code, when I dont place the code above, it is working. But when I place it back, the code is stooping its execution in the very first line this code is used.

    @prakashchhetri,

    This line:
    $mysubscribe2->add($this->email);

    Contains a $this which is incorrect. It should be $mysubscribe2.

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Subscribe to newsletter and posts – what code to add?’ is closed to new replies.