subscribe widget?
-
Hey everyone! I wanted to know if there is a sidebar widget that will allow readers to subscribe to my blog via email. I tried subscribe2 and it wont show up in the sidebar with the <!–subscribe2–> tag when used in a text box widget.
Thanks
-
TheSubscribe2 plugin is designed to only work from with a page. The code pasted below will work however the user will get no direct feedback upon submitting their email address. Anyone can feel free to tinker to get this aspect working.
Copy the code below into a suitably named file (s2widget.php) and upload this to your widgets directory then use in the normal widget way.
Matt
<?php
/*
Plugin Name: Subscribe2 widget
Description: Adds a sidebar widget for Subscribe2
Author: Matthew Robinson.
Version: 1.0
Author URI: https://www.prescriber.org.uk
*/function widget_subscribe2widget_init() {
if ( !function_exists(‘register_sidebar_widget’) )
return;function widget_subscribe2widget($args) {
extract($args);
$options = get_option(‘widget_subscribe2widget’);
$title = empty($options[‘title’]) ? __(‘Subscribe2’) : $options[‘title’];
?>
<?php echo $before_widget; ?>
<?php echo $before_title . $title . $after_title; ?>-
<form method=”post” action=””>
Your email:
<input type=”text” name=”email” value=”” size=”20″ />
<input type=”radio” name=”s2_action” value=”subscribe” checked=”checked” />Subscribe
<input type=”radio” name=”s2_action” value=”unsubscribe” />Unsubscribe
<input type=”submit” value=”Send”/>
</form><?php echo $after_widget; ?>
<?php
}
function widget_subscribe2widget_control() {
$options = $newoptions = get_option(‘widget_subscribe2widget’);
if ( $_POST[“s2w-submit”] ) {
$newoptions[‘title’] = strip_tags(stripslashes($_POST[“s2w-title”]));
}
if ( $options != $newoptions ) {
$options = $newoptions;
update_option(‘widget_subscribe2widget’, $options);
}
$title = htmlspecialchars($options[‘title’], ENT_QUOTES);
?>
<label for=”s2w-title”><?php _e(‘Title:’); ?> <input style=”width: 250px;” id=”s2w-title” name=”s2w-title” type=”text” value=”<?php echo $title; ?>” /></label>
<input type=”hidden” id=”s2w-submit” name=”s2w-submit” value=”1″ />
<?php
}// This registers our widget so it appears with the other available
// widgets and can be dragged and dropped into any active sidebars.
register_sidebar_widget(‘Subscribe2Widget’, ‘widget_subscribe2widget’);// This registers our optional widget control form.
register_widget_control(‘Subscribe2Widget’, ‘widget_subscribe2widget_control’);
}// Run our code later in case this loads prior to any required plugins.
add_action(‘plugins_loaded’, ‘widget_subscribe2widget_init’);
?>I’ve made a few changes to the above code, new widget is here:
https://www.prescriber.org.uk/sub2widget.php
Along with my version of a widgetized theme and my amended version of the Subscribe2 plugin. (Only minor changes)
Hi MattyRob,
Thanks for your work on this widget! I’m just about to upgrade + would like to hear if this is working, since I notice you are not currently using it on your site.I see you are actually using the <!–subscribe2–> tag in the sidebar, which works but the user feedback is too subtle to easily notice!
This makes me think there is a problem with his widget working as is. Before I go through the widgetizing coding just for this, I would really appreciate hearing any issues you have discovered, or if it works.
I’m hoping to provide both sub + unsub in the sidebar form, as I have in the older version when it had the separate subscribe.php file to point to. Now upgrading WP, I hope we can still have the previous UI elegance.
Thanks for your time!
I wanted to report that with WP 2.0.3, Subscribe2 v.222 works great from the sidebar, without a widget, but with a customized form.
Upgrading from 1.5.2 to 2.0.3, I got the wrong impression from all I read, that people were unable to make the form work from the sidebar, besides just linking to the subscribe page, + that this required widgetizing.
That not making sense to me, I first tested without. Even the unsubscribe works from the sidebar. Here’s how I did it:
The form’s action directs to the page, + the radio buttons’ name + actions are the same as in the form generated by the plugin. It does pass the parameters to the page, where the responses are output.
echozone,
The widget works fine for me – it should be on my site, without problems, in the sidebar.
I agree that the feedback is subtle – but is does appear where the Subscribe2 form was in the sidebar. I’m sure there are other ways around this but it works for me as it is.
MattyRob, the widget is properly activated in my widgetized theme at https://vkaryl.net/ExMachina/ (test platform), but I can’t get it to display the form, radios, etc. The basic setup shows when one views source, but for instance, viewing source on your plugins page shows the form for input, which is not showing on my page.
The other widgets I’m using for this client are working fine. Any thoughts?
vkaryl,
It’s wrking on your site as expected. If you are logged in to your blog the form will be replaced with a message about managing your profile.
Hi MattyRob…. I’d forgotten by now I asked. Yes, I did finally stumble on that conclusion. I’m a bit dim sometimes!
Thanks.
- The topic ‘subscribe widget?’ is closed to new replies.