Beee

freerides_user_widget

Sep 27th, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.86 KB | None | 0 0
  1. function freerides_user_widget() {
  2.     global $current_user;
  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( $uid, 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 // if user has registrations, otherwise go to shop
  17.                 global $EM_Events, $wpdb, $current_user, $EM_Notices, $EM_Person;
  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.             <li class=""><?php if ($bookings_count > 0) { ?><a href="/events/my-registrations" title="">My registrations</a></li>
  23.             <?php }
  24.                 // if user has events, otherwise go to submit
  25.                 $EM_Person = new EM_Person( get_current_user_id() );
  26.                 $EM_Events = $EM_Person->get_events();
  27.                 $events_count = count($EM_Events->events);
  28.             ?>
  29.             <li class=""><a href="/events/submit" title="">My events</a> <?php echo $events_count; ?></li>
  30.             <?php // if user has locations, otherwise hide
  31.                 // $EM_Locations = $EM_Person->get_locations();
  32.                 // $locs_count = count($EM_Locations->locations);
  33.             ?>
  34.             <li class=""><a href="/events/locations/edit" title="">My locations</a></li>
  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