Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion integrations/wp-registration-form/class-registration-form.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public function add_hooks()
add_action('um_after_register_fields', [ $this, 'maybe_output_checkbox' ], 20);
add_action('register_form', [ $this, 'maybe_output_checkbox' ], 20);
add_action('woocommerce_register_form', [ $this, 'maybe_output_checkbox' ], 20);
add_action('user_new_form', [ $this, 'maybe_output_user_new_checkbox' ], 20);
}

add_action('um_user_register', [ $this, 'subscribe_from_registration' ], 90, 1);
Expand All @@ -45,6 +46,35 @@ public function add_hooks()
}
}

/**
* Output checkbox in the admin "Add New User" form.
*/
public function maybe_output_user_new_checkbox($form_type)
{
if ('add-new-user' !== $form_type || $this->shown) {
return;
}

$this->shown = true;
$this->output_user_new_checkbox();
}

/**
* Output checkbox as a form-table row.
*/
public function output_user_new_checkbox()
{
$checkbox_id = esc_attr($this->checkbox_name);
echo '<table class="form-table" role="presentation">';
echo '<tr>';
echo '<th scope="row">', esc_html__('Mailchimp subscribe', 'mailchimp-for-wp'), '</th>';
echo '<td>';
$this->output_checkbox();
echo '</td>';
echo '</tr>';
echo '</table>';
}

/**
* Output checkbox, once.
*/
Expand All @@ -65,7 +95,6 @@ public function maybe_output_checkbox()
*/
public function subscribe_from_registration($user_id)
{

// was sign-up checkbox checked?
if (! $this->triggered()) {
return false;
Expand Down
Loading