How to add checkbox "Subscribe" to the custom form on my website?

Follow the instructions below in order to add "Subscribe" checkbox to your custom PHP or HTML form:

1. Install the Subscriber plugin and activate it.
2. Open the file with the form (where you would like to add checkbox "Subscribe").
3. Find a place to insert the code for the checkbox "Subscribe" output.
4. Insert the necessary lines:

if ( has_filter( 'sbscrbr_checkbox_add' ) ) {
$sbscrbr_checkbox = apply_filters( 'sbscrbr_checkbox_add', false );
if ( isset( $sbscrbr_checkbox['content'] ) ) {
echo $sbscrbr_checkbox['content'];
}
}

If the form is HTML you should insert the line with the PHP tags:

<?php if ( has_filter( 'sbscrbr_checkbox_add' ) ) {
$sbscrbr_checkbox = apply_filters( 'sbscrbr_checkbox_add', false );
if ( isset( $sbscrbr_checkbox['content'] ) ) {
echo $sbscrbr_checkbox['content'];
}
} ?>

5. Then you should add the lines to the function of the entered data checking:

if ( isset( $_POST['submit'] ) && has_filter( 'sbscrbr_checkbox_check' ) ) {
$sbscrbr_check = apply_filters( 'sbscrbr_checkbox_check', array(
'email' => isset( $_POST['email'] ) ? $_POST['email'] : ''
) );
if ( isset( $sbscrbr_check['response'] ) ) {
echo $sbscrbr_check['response']['message'];
}
}

or

<?php if ( isset( $_POST['submit'] ) && has_filter( 'sbscrbr_checkbox_check' ) ) {
$sbscrbr_check = apply_filters( 'sbscrbr_checkbox_check', array(
'email' => isset( $_POST['email'] ) ? $_POST['email'] : ''
) );
if ( isset( $sbscrbr_check['response'] ) ) {
echo $sbscrbr_check['response']['message'];
}
} ?>

where:

- $_POST['submit'] is a name of the submit form button;
- $_POST['email'] is a name of the field with entered e-mail;

Have more questions? Submit a request