SHARE
TWEET

Subscribe Form

a guest Sep 7th, 2013 82 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     global $current_user;
  3.  
  4.     $member_id = $this->get_members_by_wp_user_id( $current_user->data->ID );
  5.  
  6.     $member_data = $this->get_member( $member_id );
  7.  
  8.     if ( "" != $member_data['unsubscribe_code'] ) {
  9.         $groups = $this->get_groups();
  10.         $member_groups = $this->get_memeber_groups( $member_id );
  11.         if ( ! is_array( $member_groups ) )
  12.             $member_groups = array();
  13.  
  14.     }
  15.     //Display status message
  16.     if ( isset( $_GET['updated'] ) ) {
  17.         ?><div id="message" class="updated fade"><p><?php echo urldecode( $_GET['message'] ); ?></p></div><?php
  18.     }
  19.  
  20. ?>
  21.     <script type="text/javascript">
  22.         jQuery( document ).ready( function() {
  23.  
  24.             //save subscribes
  25.             jQuery( "#save_subscribes" ).click( function() {
  26.                 jQuery( "#newsletter_action" ).val( 'save_subscribes' );
  27.                 jQuery( "#subscribes_form" ).submit();
  28.  
  29.             });
  30.  
  31.             //unsubscribe
  32.             jQuery( "#unsubscribe" ).click( function() {
  33.                 jQuery( "#newsletter_action" ).val( 'unsubscribe' );
  34.                 jQuery( "#subscribes_form" ).submit();
  35.  
  36.             });
  37.         });
  38.     </script>
  39.  
  40.     <div class="wrap">
  41.         <h2><?php _e( 'My Subscriptions', 'email-newsletter' ) ?></h2>
  42.         <p><?php _e( 'At this page you can Subscribe or Unsubcribe to Newsletters', 'email-newsletter' ) ?></p>
  43.         <?php
  44.         if ( "" != $member_data['unsubscribe_code'] ) {
  45.         ?>
  46.         <form action="" method="post" name="subscribes_form" id="subscribes_form" >
  47.             <input type="hidden" name="newsletter_action" id="newsletter_action" value="" />
  48.             <input type="hidden" name="unsubscribe_code" value="<?php echo $member_data['unsubscribe_code']; ?>" />
  49.             <table id="subscribes_table" class="form-table">
  50.                 <tr valign="top">
  51.                     <th scope="row">
  52.                         <?php _e( 'Newsletters:', 'email-newsletter' ) ?>
  53.                     </th>
  54.                     <td>
  55.                         <?php
  56.                             $groups = $this->get_groups();
  57.                                                         $groups_echo = array();
  58.                             if ( $groups )
  59.                                 foreach( $groups as $group ){
  60.                                     if ( false === array_search ( $group['group_id'], $member_groups ) )
  61.                                         $checked = '';
  62.                                     else
  63.                                         $checked = 'checked="checked"';
  64.                                                                                
  65.                                     $groups_echo[] = '<label><input type="checkbox" name="e_newsletter_groups_id[]" ' . $checked . ' value="' . $group['group_id'] . '" />' . $group['group_name'] . '</label>';
  66.                                 }
  67.                                                         echo implode('<br/>', $groups_echo);
  68.                         ?>
  69.                     </td>
  70.                 </tr>
  71.             </table>
  72.                         <p class="submit">
  73.                                 <input class="button button-primary" type="button" id="save_subscribes" value="<?php _e( 'Save Subscribes', 'email-newsletter' ) ?>" />
  74.                                 <input class="button button-secondary" type="button" id="unsubscribe" value="<?php _e( 'Unsubscribe from all newsletters', 'email-newsletter' ) ?>" />
  75.                         </p>
  76.         </form>
  77.         <?php
  78.         } else {
  79.         ?>
  80.         <form action="" method="post" name="" id="" >
  81.             <input type="hidden" name="newsletter_action" id="subscribe" value="subscribe" />
  82.             <input class="button button-primary" type="submit" value="<?php _e( 'Subscribe on Newsletters', 'email-newsletter' ) ?>" />
  83.         </form>
  84.         <?php
  85.         }
  86.         ?>
  87.  
  88.     </div><!--/wrap-->
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top