Last active
October 12, 2023 11:47
-
-
Save mikeott/669a4997d37d6cb90e1e7811ce7b45db to your computer and use it in GitHub Desktop.
Rocket Apps: DIsable email reminders
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php //Custom user profile checkbox: | |
/* Add custom user profile field */ | |
function custom_user_profile_fields($user) { | |
?> | |
<h3>Custom User Fields</h3> | |
<table class="form-table"> | |
<tr> | |
<th> | |
<label for="no-reminders"><?php _e('No Reminders', 'your-text-domain'); ?></label> | |
</th> | |
<td> | |
<label for="admin_bar_front"> | |
<input type="checkbox" name="no-reminders" id="no-reminders" <?php checked(get_the_author_meta('no-reminders', $user->ID), true); ?> /> | |
Opt out of all license key reminders. | |
</label> | |
</td> | |
</tr> | |
</table> | |
<?php | |
} | |
add_action('show_user_profile', 'custom_user_profile_fields'); | |
add_action('edit_user_profile', 'custom_user_profile_fields'); | |
/* A Save custom user profile field */ | |
function save_custom_user_profile_fields($user_id) { | |
if (current_user_can('edit_user', $user_id)) { | |
update_user_meta($user_id, 'no-reminders', isset($_POST['no-reminders'])); | |
} | |
} | |
add_action('personal_options_update', 'save_custom_user_profile_fields'); | |
add_action('edit_user_profile_update', 'save_custom_user_profile_fields'); | |
?> | |
// Front-end form: | |
<?php | |
if (isset($_POST['update_no_reminders'])) { | |
$no_reminders = isset($_POST['no-reminders']) ? 1 : 0; | |
update_user_meta($user_ID, 'no-reminders', $no_reminders); | |
} | |
$no_reminders = get_user_meta($user_ID, 'no-reminders', true); | |
?> | |
<form method="post" action="" class="reminders-form" id="reminders-form"> | |
<input type="checkbox" name="no-reminders" id="no-reminders" value="1" <?php echo get_user_meta(get_current_user_id(), 'no-reminders', true) ? 'checked' : ''; ?>> | |
<p> | |
<strong>Disable all reminders?</strong> | |
<small>If checked, Rocket Apps will no longer email you license status reminders.</small> | |
</p> | |
<input type="hidden" name="update_no_reminders" /> | |
</form> | |
<script> | |
jQuery('#no-reminders').click(function() { | |
jQuery('#reminders-form p strong').text('Updating...'); | |
setTimeout(function() { | |
jQuery('#reminders-form').submit(); | |
}, 500); | |
}); | |
</script> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment