row output on wp-admin/users.php

View: New views
10 Messages — Rating Filter:   Alert me  

row output on wp-admin/users.php

by Daniel Cameron-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

                                        [sorry, I'm resending this since I hijacked another thread--
regardless of subject line]


Currently there's a filter for adding the column headers  
(manage_users_columns) but nothing (AFAIK) for the row output. Right  
now I'm modifying core to accomplish what we need.

Thanks in advance.



My diff for the 2.8 wp-core update is below (starts on 356 in WP 2.7):

Index: wp-admin/users.php
===================================================================
--- wp-admin/users.php (revision 4)
+++ wp-admin/users.php (working copy)
@@ -357,7 +357,7 @@
  $role = array_shift($roles);

  $style = ( ' class="alternate"' == $style ) ? '' : '  
class="alternate"';
- echo "\n\t" . user_row($user_object, $style, $role);
+ echo "\n\t" . apply_filters( 'user_row', user_row($user_object,  
$style, $role), $userid );
  }
  ?>
  </tbody>
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Stephen Rider :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Are you in essence trying to add non-existent users to the Users page?

On Jun 11, 2009, at 12:21 PM, Dan Cameron wrote:

> Currently there's a filter for adding the column headers  
> (manage_users_columns) but nothing (AFAIK) for the row output. Right  
> now I'm modifying core to accomplish what we need.

_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Daniel Cameron-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Are you in essence trying to add non-existent users to the Users page?


No, I'm outputting additional user information. For example,  
membership status.
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Daniel Cameron-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

To anyone interested. We found it.

manage_users_custom_column



On Jun 11, 2009, at 11:42 AM, Stephen Rider wrote:

> Are you in essence trying to add non-existent users to the Users page?
>
> On Jun 11, 2009, at 12:21 PM, Dan Cameron wrote:
>
>> Currently there's a filter for adding the column headers  
>> (manage_users_columns) but nothing (AFAIK) for the row output.  
>> Right now I'm modifying core to accomplish what we need.


_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Daniel Cameron-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> manage_users_custom_column

I should mention that function only works in WP 2.8, looks like  
someone ran into the same problem and fixed it in a more elegant  
solution.


_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Claudio Simeone :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/6/12 Dan Cameron <dan@...>:
>> manage_users_custom_column
>
> I should mention that function only works in WP 2.8, looks like someone ran
> into the same problem and fixed it in a more elegant solution.


Hi,

seems that this hook does not work good in 2.8.1. I'm trying to add a
custom column with these functions:

add_filter('manage_users_columns', 'my_user_cols_columns'); // this works
add_action('manage_users_custom_column', my_user_cols_cc'); // this not

function my_user_cols_columns($defaults) {
    $defaults['courses'] = 'My Column';
    return $defaults;
}

function my_user_cols_cc($column, $user) {
if( $column == 'courses' ) {
    echo '=>'.$user;
    }
}

but it seems that the function my_user_cols_cc does not receive the
arguments. Or at least it does not work same as the post columns.
Googling around, I found this post:
http://blog.5ubliminal.com/posts/incoherency-in-wordpress-custom-columns-actions-vs-filters/

So my question is: the issues explained in this post, have been fixed?
If i try to apply this patch to wp-admin/includes/template.php

ob_start(); // Start ob
do_action('manage_users_custom_column', $column_name, $user_object->ID);
$res = ob_get_contents(); // Get ob contents
ob_end_clean(); // Clean ob
$r .= $res; // Append captured output

it passes the column_name, but not the user id. The same as if i modify:

$r .= apply_filters('manage_users_custom_column', '',$column_name,
$user_object->ID);
to
$r .= apply_filters('manage_users_custom_column', $column_name,
$user_object->ID);

is this a bug or I did not understand good how this hook works?

thanks in advance
CLS
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Matt Mullenweg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On 7/16/2009 10:05 AM, Claudio Simeone wrote:
> add_action('manage_users_custom_column', my_user_cols_cc'); // this not

You're missing an opening quote there -- is that in the original code or
a copy/paste error?

If your action function accepts multiple arguments, you need to tell
add_action as well:

http://codex.wordpress.org/Function_Reference/add_action

--
Matt Mullenweg
http://ma.tt | http://wordpress.org | http://automattic.com
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Claudio Simeone :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/7/19 Matt Mullenweg <m@...>:

>> add_action('manage_users_custom_column', my_user_cols_cc'); // this not
>
> You're missing an opening quote there -- is that in the original code or a
> copy/paste error?

hi Matt, the original code has the opening quote, I made a paste error
while I was writing the email.

> If your action function accepts multiple arguments, you need to tell
> add_action as well:
>
> http://codex.wordpress.org/Function_Reference/add_action

yes, my function accepts 2 arguments: the column_name and the user ID,
I told add_action this, and now it's working but in a different and
strange way:

so I did:

add_action('manage_users_custom_column', 'MY_user_cols_cc', 10, 3);

function MY_user_cols_cc($empty_var, $user_object, $column_name) {
/*
strange thing #1:
$user_object contains the value of $column_name and
$column_name contains the value of $user_object

strange thing #2:
why I need to pass an empty variable as first argument?
*/

if ($user_object == 'courses'){
  // do what you need
  $r .= "This user has this ID: $column_name";
}
return $r;
}

can you explain to me why this happens?
the function is hooked to this row in /wp-admin/includes/template.php row 1975
that has an empty argument (the second)

$r .= apply_filters('manage_users_custom_column', '', $column_name,
$user_object->ID);

A final question: will this solution work in future versions of WP?

thanks
Claudio
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Matt Martz-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

> so I did:
>
> add_action('manage_users_custom_column', 'MY_user_cols_cc', 10, 3);
>
> function MY_user_cols_cc($empty_var, $user_object, $column_name) {
> /*
> strange thing #1:
> $user_object contains the value of $column_name and
> $column_name contains the value of $user_object

If you look at where manage_users_custom_column is defined in the code
you will see:

apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);

Where $column_name is the 2nd argument and $user_object->ID is the 3rd argument.

You have the arguments reversed in your callback function.

--
Matt Martz
matt@...
http://sivel.net/
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers

Re: row output on wp-admin/users.php

by Claudio Simeone :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

2009/7/20 Matt Martz <matt@...>:

> If you look at where manage_users_custom_column is defined in the code
> you will see:
>
> apply_filters('manage_users_custom_column', '', $column_name, $user_object->ID);
>
> Where $column_name is the 2nd argument and $user_object->ID is the 3rd argument.
>
> You have the arguments reversed in your callback function.

yes, I noticed it 1 second after the mail was sent :)

do you know why manage_users_custom_column  (and similar functions)
have an empty argument?

apply_filters('manage_users_custom_column', '' <====

thanks
Claudio
_______________________________________________
wp-hackers mailing list
wp-hackers@...
http://lists.automattic.com/mailman/listinfo/wp-hackers