Beee

freerides_user_widget_working

Sep 30th, 2013
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.97 KB | None | 0 0
  1. function freerides_user_widget() {
  2.     global $current_user, $EM_Events, $EM_Bookings, $EM_Person;
  3.     get_currentuserinfo();
  4.     $uid = $current_user->ID;
  5. ?>
  6.     <aside id="userpanel" class="widget widget_userpanel">
  7.         <h3 class="widget-title">Welcome <? echo $current_user->display_name; ?></h3>
  8.         <?php
  9.             $userpic = get_avatar( get_current_user_id(), 70 );
  10.             if ( $userpic ) {
  11.         ?>
  12.         <div class="userpic"><?php echo $userpic; ?></div>
  13.         <?php } ?>
  14.         <ul>
  15.             <li class=""><a href="/your-profile" title="">My profile</a></li>
  16.             <?php
  17.                 // if user has registrations
  18.                 $EM_Person = new EM_Person( get_current_user_id() );
  19.                 $EM_Bookings = $EM_Person->get_bookings();
  20.                 $bookings_count = count($EM_Bookings->bookings);
  21.                
  22.                 if ($bookings_count > 0) { ?><li class=""><a href="/events/my-registrations" title="">My registrations</a></li><?php }
  23.  
  24.                 // if user has events, otherwise go to submit
  25.                 $EM_Events = EM_Events::get(array('owner'=>get_current_user_id(), 'scope'=>'all'));
  26.                 $events_count = count($EM_Events);
  27.             ?>
  28.             <li class=""><?php if ($events_count > 0) { ?><a href="/events/submit" title="">My events</a><?php } else { ?><a href="/events/submit/?action=edit" title="">Submit an event</a><?php } ?></li>
  29.             <?php
  30.                 // if user has locations, otherwise hide
  31.                 $EM_Locations = EM_Locations::get(array('owner'=>get_current_user_id(), 'scope'=>'all'));
  32.                 $locations_count = count($EM_Locations);
  33.                
  34.                 if ($locations_count > 0) { ?><li class=""><a href="/events/locations/edit" title="">My locations</a></li><?php } ?>
  35.             <li class=""><a href="<?php echo wp_logout_url( get_permalink() ); ?>">Log out</a></li>
  36.         </ul>
  37.         <div class="clear"></div>
  38.     </aside>
  39. <?php
  40.     }  
  41.  
  42. wp_register_sidebar_widget(
  43.     'freerides_login_widget',               // your unique widget id
  44.     'User panel',                                       // widget name
  45.     'freerides_user_widget',            // callback function
  46.     array(                                                  // options
  47.         'description' => 'Widget voor user panel'
  48.     )
  49. );
Add Comment
Please, Sign In to add comment