Advertisement
Beee

widget_s2user.php

May 25th, 2015
381
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.18 KB | None | 0 0
  1. <?php
  2. class S2widget extends WP_Widget {
  3.  
  4.     function S2widget() {
  5.         // Instantiate the parent object
  6.         parent::__construct(
  7.                     's2member_user', // Base ID
  8.                     'IDF User widget', // Name
  9.                     array( 'description' => 'Customized S2member User widget' ) // Args
  10.         );
  11.     }
  12.  
  13.     function widget( $args, $instance ) {
  14.         // add check to see if buddypress and s2 member are active
  15.        
  16.     global $EM_Bookings;
  17.     global $EM_Person;
  18.     // global $wpdb;
  19.     extract( $args );
  20.         $siteurl                    = home_url();
  21.     $tc_widgettitle     = "My IDF";
  22.         $EM_Person              = get_current_user_id();
  23.        
  24.         // $EM_Bookings             = $EM_Person->get_bookings();
  25.         // $bookings_count      = count($EM_Bookings->bookings);
  26.         if ( $bookings_count > 0 ) {
  27.  
  28.             // if has bookings, output link to bookings page
  29.             $registrationslink = '<br /><a href="'.$siteurl.'/my-idf/registrations/">My registrations</a>';
  30.            
  31.             // Get events here in one query to speed things up
  32.             $event_ids = array();
  33.             foreach ( $EM_Bookings as $EM_Booking ) {
  34.                 $event_ids[] = $EM_Booking->event_id;
  35.             }
  36.         }
  37.        
  38.         // Widget output
  39.         echo $before_widget;
  40.         if ( $tc_widgettitle ) echo $before_title . $tc_widgettitle . $after_title;
  41.        
  42.         // echo '<p>'.$EM_Person.'</p>';
  43.  
  44.         // echo '<pre>' . $EM_Person . '</pre>';
  45.        
  46.     if ( is_user_logged_in() ) {
  47.             echo s2member_pro_login_widget( array( "title" => "", "profile_title" => "", "display_gravatar" => "1", "link_gravatar" => "0", "login_redirect" => "%%previous%%", "logout_redirect" => "%%previous%%", "signup_url" => "", "my_profile_url" => "", "my_account_url" => "", "logged_in_code" => "<a href='".$siteurl."/my-idf/profile/'>My account</a><br /><a href='".$siteurl."/my-idf/registrations/'>My registrations</a>" ) );
  48.     } else {
  49.             echo s2member_pro_login_widget( array( "title" => "", "profile_title" => "", "display_gravatar" => "1", "link_gravatar" => "0", "login_redirect" => "%%previous%%", "logout_redirect" => "%%previous%%", "signup_url" => "", "my_profile_url" => "", "my_account_url" => "", "logged_in_code" => "<a href='".$siteurl."/my-idf/profile/'>My account</a><br /><a href='".$siteurl."/my-idf/registrations/'>My registrations</a>" ) );
  50.     }
  51.  
  52.     echo $after_widget;
  53.     }
  54.  
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement