Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

Show Registration Date

By: Ipstenu on Mar 9th, 2011  |  syntax: PHP  |  size: 2.06 KB  |  views: 1,505  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <?php
  2.  
  3. /*
  4. Plugin Name: Show Registration Date
  5. Description: Show registration date
  6. Version: 0.1
  7. Author: Ipstenu
  8. Author URI: http://www.ipstenu.org/
  9.  
  10.         This plugin is free software; you can redistribute it and/or modify
  11.         it under the terms of the GNU General Public License as published by
  12.         the Free Software Foundation; either version 2 of the License, or
  13.         (at your option) any later version.
  14.  
  15.         This plugin is distributed in the hope that it will be useful,
  16.         but WITHOUT ANY WARRANTY; without even the implied warranty of
  17.         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18.         GNU General Public License for more details.
  19.  
  20. */
  21.  
  22. // Register the column - Registered
  23. function registerdate($columns) {
  24.     $columns['registerdate'] = __('Registered', 'registerdate');
  25.     return $columns;
  26. }
  27. add_filter('manage_users_columns', 'registerdate');
  28.  
  29. // Display the column content
  30. function registerdate_columns( $value, $column_name, $user_id ) {
  31.         if ( 'registerdate' != $column_name )
  32.            return $value;
  33.         $user = get_userdata( $user_id );
  34.         $registerdate = $user->user_registered;
  35.         //$registerdate = date("Y-m-d", strtotime($registerdate));
  36.         return $registerdate;
  37. }
  38. add_action('manage_users_custom_column',  'registerdate_columns', 10, 3);
  39.  
  40. function registerdate_column_sortable($columns) {
  41.           $custom = array(
  42.       // meta column id => sortby value used in query
  43.           'registerdate'    => 'registered',
  44.           );
  45.       return wp_parse_args($custom, $columns);
  46. }
  47.  
  48. add_filter( 'manage_users_sortable_columns', 'registerdate_column_sortable' );
  49.  
  50. function registerdate_column_orderby( $vars ) {
  51.         if ( isset( $vars['orderby'] ) && 'registerdate' == $vars['orderby'] ) {
  52.                 $vars = array_merge( $vars, array(
  53.                         'meta_key' => 'registerdate',
  54.                         'orderby' => 'meta_value'
  55.                 ) );
  56.         }
  57.  
  58.         return $vars;
  59. }
  60.  
  61. add_filter( 'request', 'registerdate_column_orderby' );
  62. ?>