-
Notifications
You must be signed in to change notification settings - Fork 0
/
wpum-newsletter.php
39 lines (35 loc) · 1.01 KB
/
wpum-newsletter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/*
Plugin Name: WPUM Newsletter
Plugin URI: https://wpusermanager.com
Description: WP User Manager addon for the Newsletter plugin.
Version: 1.0
Author: WP User Manager
Author URI: https://wpusermanager.com/
License: GPLv3+
*/
/**
* Add the Newsletter optin checkbox to the registration form
*
* @param array $fields
*
* @return array
*/
function wpum_newsletter_add_optin( $fields ) {
$newsletter_options = get_option( 'newsletter_wpusers', array() );
if ( ! empty( $newsletter_options['subscribe'] ) && $newsletter_options['subscribe'] != 1 ) {
$fields['newsletter'] = array(
'label' => '',
'type' => 'checkbox',
'description' => $newsletter_options['subscribe_label'],
'priority' => 9999,
'required' => false,
'value' => $newsletter_options['subscribe'] == 3,
);
}
return $fields;
}
add_action( 'newsletter_init', 'wpum_newsletter_init' );
function wpum_newsletter_init() {
add_filter( 'wpum_get_registration_fields', 'wpum_newsletter_add_optin' );
}