PriMoThemes — now s2Member® (official notice)

This is now a very OLD forum system. It's in READ-ONLY mode.
All community interaction now occurs at WP Sharks™. See: new forums @ WP Sharks™

Add EOT to all users view

s2Member Plugin. A Membership plugin for WordPress®.

Add EOT to all users view

Postby redliontrader » September 4th, 2011, 12:45 pm

Is there a way to add the EOT field to the All Users view. Would be even better if it were a sortable column. Will do the work if someone can get me started.

Thanks
User avatar
redliontrader
Registered User
Registered User
 
Posts: 15
Joined: August 27, 2011

Re: Add EOT to all users view

Postby Bruce C » September 4th, 2011, 3:55 pm

I found out how to create a column in the Users list, however I am still looking through the docs for the EOT Constants/Variables.... I'll get back to you if I figure it out, but here's the current code I have:

Code: Select all
<?php
//Two main filters,
add_filter('manage_users_columns', 'add_eot_column');
add_filter('manage_users_custom_column', 'view_eot_column', 10, 3);

function add_eot_column($columns) {
          $columns['current_eot'] = 'EOT';
   return $columns;

}

function view_eot_column($empty='', $column_name, $id) {
   if( $column_name == 'current_eot' ) {
                //The return below is what is shown.
      return  ;

       }
}
?>


This, as it is, only creates the column with the name of EOT.

I'll look at it a bit more.


BTW, found the original code here:
http://wordpress.org/support/topic/mana ... ?replies=6
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Add EOT to all users view

Postby Bruce C » September 4th, 2011, 4:45 pm

Here you go, I got it figured out:

Code: Select all
<?php
add_filter ('manage_users_columns', 'add_eot_column');
add_filter ('manage_users_custom_column', 'view_eot_column', 10, 3);
function add_eot_column ($columns)
   {
      $columns['view_eot'] = 'EOT';
      return $columns;
   }
function view_eot_column ($empty = '', $column_name, $id)
   {
      if ($column_name == 'view_eot')
         {
            if (!get_user_field ('s2member_auto_eot_time', $id) == 0)
               {
                  return date ("M/d/Y", get_user_field ('s2member_auto_eot_time', $id));
               }
            else
               {
                  return "No EOT Set";
               }
         }
   }
?>


This should go either in your theme's functions.php file, the s2hacks.php file, OR a plugin file you create yourself.

Cheers!
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Add EOT to all users view

Postby redliontrader » September 10th, 2011, 8:39 am

Ace.. that is awesome.. Two problems for me though.

If I add it to functions.php it breaks the other columns (num of logins for example don't appear).

Where does s2hacks.php go? In my theme folder? I was going to try it there
User avatar
redliontrader
Registered User
Registered User
 
Posts: 15
Joined: August 27, 2011

Re: Add EOT to all users view

Postby Bruce C » September 10th, 2011, 7:44 pm

I'm taking another look at this. I'm sorry I didn't see that before.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Add EOT to all users view

Postby Bruce C » September 10th, 2011, 8:10 pm

Here you go, it was an issue with where I had the return values.

Here's the correct code

Code: Select all
add_filter ('manage_users_columns', 'add_eot_column');
add_filter ('manage_users_custom_column', 'view_eot_column', 11, 3);
function add_eot_column ($eot_column)
   {
      $eot_column['view_eot'] = 'EOT';
      return $eot_column;
   }
function view_eot_column ($eot_column, $column_name, $id)
   {
      if ($column_name == 'view_eot')
         {
            if (!get_user_field ('s2member_auto_eot_time', $id) == 0)
               {
                  $eot_column = date ("M/d/Y", get_user_field ('s2member_auto_eot_time', $id));
               }
         }
      return $eot_column;
   }
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Add EOT to all users view

Postby Cristián Lávaque » September 14th, 2011, 2:39 am

The s2hacks.php file would go in the /wp-content/mu-plugins/ directory. I.e.: /wp-content/mu-plugins/s2hacks.php :)

Just create the dir and file if you don't have them.
Cristián Lávaque http://s2member.net
Is s2Member working for you? Please rate it Image at WordPress.org. Thanks! :)
User avatar
Cristián Lávaque
Developer
Developer
 
Posts: 6836
Joined: December 22, 2010

Re: Add EOT to all users view

Postby pcscweb » September 19th, 2011, 8:00 pm

This mod is great!

redliontrader wrote: Would be even better if it were a sortable column.


From what I've read, sorting by the EOT column may not be possible because the values are stored in the wp_usermeta table: http://tech.ipstenu.org/2011/limitations-on-sortable-columns/.
User avatar
pcscweb
Registered User
Registered User
 
Posts: 6
Joined: September 11, 2011

Re: Add EOT to all users view

Postby Bruce C » September 21st, 2011, 11:18 am

Thanks pcsweb for posting that.

I took a look at the filters that were used the the plugin from that post, and managed to get the column sortable. Here's the code:

Code: Select all
add_filter ('manage_users_columns', 'add_eot_column');
add_filter ('manage_users_custom_column', 'view_eot_column', 11, 3);
function add_eot_column ($eot_column)
   {
      $eot_column['view_eot'] = 'EOT';
      return $eot_column;
   }
function view_eot_column ($eot_column, $column_name, $id)
   {
      if ($column_name == 'view_eot')
         {
            if (!get_user_field ('s2member_auto_eot_time', $id) == 0)
               {
                  $eot_column = date ("M/d/Y", get_user_field ('s2member_auto_eot_time', $id));
               }
         }
      return $eot_column;
   }
function eot_sortable_columns ($columns)
   {
      $columns['view_eot'] = 'EOT';
      return $columns;
   }
add_filter ('manage_users_sortable_columns', 'eot_sortable_columns');
function eot_column_orderby ($vars)
   {
      if (isset ($vars['orderby']) && 'view_eot' == $vars['orderby'])
         {
            $vars = array_merge ($vars, array ('meta_key' => 'view_eot', 'orderby' => 'meta_value', 'order' => 'asc'));
         }
      return $vars;
   }
add_filter ('request', 'eot_column_orderby');


I'm happy we figured this out!
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Add EOT to all users view

Postby Bruce C » September 21st, 2011, 11:19 am

Also, I just wanted to bring up that there's a chance that this may not work on a multisite installation. You can try it, though.
~Bruce ( a.k.a. Ace )

If you're interested in a Professional Installation, or Custom Coding Job, you can send your request here.

Proud Supporter of:
The Zeitgeist Movement
and Occupy Everything
User avatar
Bruce C
Experienced User
Experienced User
 
Posts: 337
Joined: July 20, 2011

Re: Add EOT to all users view

Postby bitofgrace » September 21st, 2011, 12:36 pm

This is fantastic Ace - thank you :)
User avatar
bitofgrace
Registered User
Registered User
 
Posts: 64
Joined: September 8, 2011

Re: Add EOT to all users view

Postby pcscweb » September 22nd, 2011, 7:23 pm

It seems to be sorting by Username when I try clicking on the 'EOT' column. Is it working for you?

One thing I noticed was that:

Code: Select all
'view_eot' == $vars['orderby']


should probably be

Code: Select all
'EOT' == $vars['orderby']


to reflect the correct value in the URL-encoded query string param. Fixing that still resulted in the rows sorting by Username instead of EOT.
User avatar
pcscweb
Registered User
Registered User
 
Posts: 6
Joined: September 11, 2011


Return to s2Member Plugin

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron