function invite_anyone_opt_out_screen() { global $bp; if (isset($_POST['oops_submit'])) { $oops_email = urlencode(stripslashes($_POST['opt_out_email'])); $opt_out_link = add_query_arg(array('iaaction' => 'accept-invitation', 'email' => $oops_email), bp_get_root_domain() . '/' . bp_get_signup_slug() . '/'); bp_core_redirect($opt_out_link); } $opt_out_button_text = __('Opt Out', 'invite-anyone'); $oops_button_text = __('Accept Invitation', 'invite-anyone'); $sitename = get_bloginfo('name'); $opt_out_message = sprintf(__('To opt out of future invitations to %s, make sure that your email is entered in the field below and click "Opt Out".', 'invite-anyone'), $sitename); $oops_message = sprintf(__('If you are here by mistake and would like to accept your invitation to %s, click "Accept Invitation" instead.', 'invite-anyone'), $sitename); if (bp_is_register_page() && isset($_GET['iaaction']) && 'opt-out' === urldecode($_GET['iaaction'])) { get_header(); ?> <div id="content"> <div class="padder"> <?php if (!empty($_POST['opt_out_submit'])) { ?> <?php if ($_POST['opt_out_submit'] == $opt_out_button_text && ($email = urldecode($_POST['opt_out_email']))) { ?> <?php $email = str_replace(' ', '+', $email); ?> <?php check_admin_referer('invite_anyone_opt_out'); ?> <?php if (invite_anyone_mark_as_opt_out($email)) { ?> <?php $opted_out_message = __('You have successfully opted out. No more invitation emails will be sent to you by this site.', 'invite-anyone'); ?> <p><?php echo $opted_out_message; ?> </p> <?php } else { ?> <p><?php _e('Sorry, there was an error in processing your request', 'invite-anyone'); ?> </p> <?php } ?> <?php } else { ?> <?php /* I guess this should be some sort of error message? */ ?> <?php } ?> <?php } else { ?> <?php if (isset($_GET['email']) && ($email = $_GET['email'])) { ?> <script type="text/javascript"> jQuery(document).ready( function() { jQuery("input#opt_out_email").val("<?php echo str_replace(' ', '+', urldecode($email)); ?> "); }); </script> <?php } ?> <form action="" method="post"> <?php do_action('invite_anyone_before_optout_messages'); ?> <p><?php echo $opt_out_message; ?> </p> <p><?php echo $oops_message; ?> </p> <?php do_action('invite_anyone_after_optout_messages'); ?> <?php wp_nonce_field('invite_anyone_opt_out'); ?> <p><?php _e('Email:', 'invite-anyone'); ?> <input type="text" id="opt_out_email" name="opt_out_email" size="50" /></p> <p><input type="submit" name="opt_out_submit" value="<?php echo $opt_out_button_text; ?> " /> <input type="submit" name="oops_submit" value="<?php echo $oops_button_text; ?> " /> </p> </form> <?php } ?> </div> </div> <?php get_footer(); die; } }
function invite_anyone_opt_out_screen() { global $bp; if (isset($_POST['oops_submit'])) { bp_core_redirect(site_url(BP_REGISTER_SLUG) . '/accept-invitation/' . urlencode($_POST['opt_out_email'])); } $opt_out_button_text = __('Opt Out', 'bp-invite-anyone'); $oops_button_text = __('Accept Invitation', 'bp-invite-anyone'); $sitename = get_bloginfo('name'); $opt_out_message = sprintf(__('To opt out of future invitations to %s, make sure that your email is entered in the field below and click "Opt Out".', 'bp-invite-anyone'), $sitename); $oops_message = sprintf(__('If you are here by mistake and would like to accept your invitation to %s, click "Accept Invitation" instead.', 'bp-invite-anyone'), $sitename); if ($bp->current_component == BP_REGISTER_SLUG && $bp->current_action == 'opt-out') { get_header(); ?> <div id="content"> <div class="padder"> <?php if ($bp->action_variables[1] == 'submit') { ?> <?php if ($_POST['opt_out_submit'] == $opt_out_button_text && ($email = urldecode($_POST['opt_out_email']))) { ?> <?php check_admin_referer('invite_anyone_opt_out'); ?> <?php if (invite_anyone_mark_as_opt_out($email)) { ?> <?php $opted_out_message = __('You have successfully opted out. No more invitation emails will be sent to you by this site.', 'bp-invite-anyone'); ?> <p><?php echo $opted_out_message; ?> </p> <?php } else { ?> <p><?php _e('Sorry, there was an error in processing your request', 'bp-invite-anyone'); ?> </p> <?php } ?> <?php } else { ?> <?php /* I guess this should be some sort of error message? */ ?> <?php } ?> <?php } else { ?> <?php if ($email = $bp->action_variables[0]) { ?> <script type="text/javascript"> jQuery(document).ready( function() { jQuery("input#opt_out_email").val("<?php echo urldecode($email); ?> "); }); </script> <?php } ?> <form action="<?php echo $email; ?> /submit" method="post"> <?php do_action('invite_anyone_before_optout_messages'); ?> <p><?php echo $opt_out_message; ?> </p> <p><?php echo $oops_message; ?> </p> <?php do_action('invite_anyone_after_optout_messages'); ?> <?php wp_nonce_field('invite_anyone_opt_out'); ?> <p><?php _e('Email:', 'bp-invite-anyone'); ?> <input type="text" id="opt_out_email" name="opt_out_email" size="50" /></p> <p><input type="submit" name="opt_out_submit" value="<?php echo $opt_out_button_text; ?> " /> <input type="submit" name="oops_submit" value="<?php echo $oops_button_text; ?> " /> </p> </form> <?php } ?> </div> </div> <?php get_footer(); die; } }