waterprism
09-23-2011, 06:32 PM
Hi,
Would really appreciate your help with something.
I've got an email capture form plugin in my WordPress sidebar. It redirects to a success url as is standard. I'd much prefer visitors to stay on the page they signed up from, with just the success message output into a div under the form or along those lines, so they stay on the page. I'm sure you know the kind of thing I mean.
I've Googled around but can't find anything like that (probably partly because I'm not sure of the correct search terms to use). There was one javascript solution I came across that went like this --
//in the head
<script type="text/javascript">
function showit(){
document.getElementById('success').style.visibility = 'visible';
}
</script>
//in the body
<div id="success" style="visibility: visible">SUCCESS MESSAGE HERE</div>
-- But that doesn't seem to work (or I'm doing it wrong).
So, I'm really sorry to dump a chunk of code on you from the plugin, but I'm not exactly sure where the relevant bits are to alter to get the functionality I'm looking for. Thanks so much.
<?php
function wp_email_capture_form($error = 0)
{
$url = get_option('home');
$url = addLastCharacter($url);
?> <div id="wp_email_capture"><form name="wp_email_capture" method="post" action="<?php echo $url; ?>">
<?php if (isset($_GET["wp_email_capture_error"])) {
$error = sanitize($_GET["wp_email_capture_error"]);
echo "<div style='width:80%;background-color: #FFCCCC; margin: 5px;font-weight'>Error: ". $error ."</div>";
} ?>
<label class="wp-email-capture-name">Name:</label> <input name="wp-email-capture-name" type="text" class="wp-email-capture-name"><br/>
<label class="wp-email-capture-email">Email:</label> <input name="wp-email-capture-email" type="text" class="wp-email-capture-email"><br/>
<input type="hidden" name="wp_capture_action" value="1">
<input name="Submit" type="submit" value="Submit" class="wp-email-capture-submit">
</form>
</div>
<?php if (get_option("wp_email_capture_link") == 1) {
echo "<p style='font-size:10px;'>Powered by <a href='site.com' target='_blank'>site</a></p>\n";
}
}
function wp_email_capture_form_page($error = 0)
{
$url = get_option('home');
$url = addLastCharacter($url);
$display .= "<div id='wp_email_capture_2'><form name='wp_email_capture_display' method='post' action='" . $url ."'>\n";
if (isset($_GET["wp_email_capture_error"])) {
$error = sanitize($_GET["wp_email_capture_error"]);
$display .= "<div style='width:80%;background-color: #FFCCCC; margin: 5px;font-weight'>Error: ". $error ."</div>\n";
}
$display .= "<label class='wp-email-capture-name'>Name:</label> <input name='wp-email-capture-name' type='text' class='wp-email-capture-name'><br/>\n";
$display .= "<label class='wp-email-capture-email'>Email:</label> <input name='wp-email-capture-email' type='text' class='wp-email-capture-email'><br/>\n";
$display .= "<input type='hidden' name='wp_capture_action' value='1'>\n";
$display .= "<input name='Submit' type='submit' value='Submit' class='wp-email-capture-submit'></form></div>\n";
if (get_option("wp_email_capture_link") == 1) {
$display .= "<p style='font-size:10px;'>Powered by <a href='site.com' target='_blank'>site</a></p>\n";
}
return $display;
}
function wp_email_capture_display_form_in_post($content)
{
$get_form = wp_email_capture_form_page();
$content = str_replace("[wp_email_capture_form]", $get_form, $content);
return $content;
}
?>
Thanks a lot.
Would really appreciate your help with something.
I've got an email capture form plugin in my WordPress sidebar. It redirects to a success url as is standard. I'd much prefer visitors to stay on the page they signed up from, with just the success message output into a div under the form or along those lines, so they stay on the page. I'm sure you know the kind of thing I mean.
I've Googled around but can't find anything like that (probably partly because I'm not sure of the correct search terms to use). There was one javascript solution I came across that went like this --
//in the head
<script type="text/javascript">
function showit(){
document.getElementById('success').style.visibility = 'visible';
}
</script>
//in the body
<div id="success" style="visibility: visible">SUCCESS MESSAGE HERE</div>
-- But that doesn't seem to work (or I'm doing it wrong).
So, I'm really sorry to dump a chunk of code on you from the plugin, but I'm not exactly sure where the relevant bits are to alter to get the functionality I'm looking for. Thanks so much.
<?php
function wp_email_capture_form($error = 0)
{
$url = get_option('home');
$url = addLastCharacter($url);
?> <div id="wp_email_capture"><form name="wp_email_capture" method="post" action="<?php echo $url; ?>">
<?php if (isset($_GET["wp_email_capture_error"])) {
$error = sanitize($_GET["wp_email_capture_error"]);
echo "<div style='width:80%;background-color: #FFCCCC; margin: 5px;font-weight'>Error: ". $error ."</div>";
} ?>
<label class="wp-email-capture-name">Name:</label> <input name="wp-email-capture-name" type="text" class="wp-email-capture-name"><br/>
<label class="wp-email-capture-email">Email:</label> <input name="wp-email-capture-email" type="text" class="wp-email-capture-email"><br/>
<input type="hidden" name="wp_capture_action" value="1">
<input name="Submit" type="submit" value="Submit" class="wp-email-capture-submit">
</form>
</div>
<?php if (get_option("wp_email_capture_link") == 1) {
echo "<p style='font-size:10px;'>Powered by <a href='site.com' target='_blank'>site</a></p>\n";
}
}
function wp_email_capture_form_page($error = 0)
{
$url = get_option('home');
$url = addLastCharacter($url);
$display .= "<div id='wp_email_capture_2'><form name='wp_email_capture_display' method='post' action='" . $url ."'>\n";
if (isset($_GET["wp_email_capture_error"])) {
$error = sanitize($_GET["wp_email_capture_error"]);
$display .= "<div style='width:80%;background-color: #FFCCCC; margin: 5px;font-weight'>Error: ". $error ."</div>\n";
}
$display .= "<label class='wp-email-capture-name'>Name:</label> <input name='wp-email-capture-name' type='text' class='wp-email-capture-name'><br/>\n";
$display .= "<label class='wp-email-capture-email'>Email:</label> <input name='wp-email-capture-email' type='text' class='wp-email-capture-email'><br/>\n";
$display .= "<input type='hidden' name='wp_capture_action' value='1'>\n";
$display .= "<input name='Submit' type='submit' value='Submit' class='wp-email-capture-submit'></form></div>\n";
if (get_option("wp_email_capture_link") == 1) {
$display .= "<p style='font-size:10px;'>Powered by <a href='site.com' target='_blank'>site</a></p>\n";
}
return $display;
}
function wp_email_capture_display_form_in_post($content)
{
$get_form = wp_email_capture_form_page();
$content = str_replace("[wp_email_capture_form]", $get_form, $content);
return $content;
}
?>
Thanks a lot.