Hi,
You might want to make a query for each user in the row instead.
For reference: https://developer.ww.wp.xz.cn/reference/hooks/manage_users_custom_column/
Then you might do
add_filter('manage_users_custom_column', function($value, $column, $user_id) {
if ($column === "eth_address") {
$address = \losnappas\Ethpress\Address::find_by_user($user_id);
if (!is_wp_error($address) {
$value = $address->get_coinbase();
}
}
return $value
}
For reference: https://gitlab.com/losnappas/ethpress/-/blob/master/app/Address.php#L259
That might work. Didn’t actually test that code, I’m a bit occupied with other stuff. Let me know if that one works!
That code also gets just one address, but you can copy and paste the code from the GitLab link, and modify it to return em all!
Let me know how it works!
-
This reply was modified 5 years, 4 months ago by
lynn999.
Thread Starter
JSSdev
(@jonatest)
Hi Lynn999, thanks for your quick response, well, I’ll take a closer look at it of course, I tried to paste this code into the functions.php, for now it only creates the column, your code just crashes, but its my fault for sure since I don’t have much more knowledge in PHP.
This is what I pasted in functions.php, without succeed.
add_action('manage_users_columns','eth_modify_user_columns');
function eth_modify_user_columns($column_headers) {
$column_headers['eth_address'] = 'ETHaddress';
return $column_headers;
}
add_filter('manage_users_custom_column', function($value, $column, $user_id) {
if ($column === "eth_address") {
$address = \losnappas\Ethpress\Address::find_by_user($user_id);
if (!is_wp_error($address)) {
$value = $address->get_coinbase();
}
}
return $value;
})
Also debuged code syntax etc.. and tried to put a different ..\losnappas\Ethpress\Address.. path so I can see why it fails but I don’t have any skills into debuging php code from WordPress yet, CSS, JS, jQuery, Html debugging is so much easy for me but PHP I just see it crashes but don’t know why hehe.
Thanks for your time and I hope you can still develop this plugin since it’s going to be a huge year for NFT tokens membership sites and will get much more attention.
add_action('manage_users_columns','eth_modify_user_columns');
function eth_modify_user_columns($column_headers) {
$column_headers['eth_address'] = 'ETHaddress';
return $column_headers;
}
add_filter('manage_users_custom_column', function($value, $column, $user_id) {
if ($column === "eth_address") {
$address = \losnappas\Ethpress\Address::find_by_user($user_id);
if (!is_wp_error($address)) {
$value = $address->get_coinbase();
}
}
return $value;
}, 10, 3)
Added the “, 10, 3” there at the end.
https://codex.ww.wp.xz.cn/WP_DEBUG read that
You can also try wp_die("test") to see where it’s crashing and so on.
Yeah, it’s a nice plugin, too bad I’m so busy, though… It’ll be a slower time for now at least from my part, looking for contributors.
Thread Starter
JSSdev
(@jonatest)
It worked like a charm!! I also tried the debug and I’m getting used to, not the chrome console but its enough.
Now I’ll try to make that data be stored into the usermeta custom table (I thought that it was going to be added, but it’s all like visible but not stored) I will then be able to export a CSV including that ETH addresses.
Screenshot
I hope I can help more in the future, for now, I would like to give you my po translations es_ES, if I manage to do more things I’ll be here around for sure.
es_ES po-mo Wetransfer
-
This reply was modified 5 years, 4 months ago by
JSSdev.
Nice!
I can give advice once you have some working code again, so don’t be afraid to ask.
This time it sounds like you’ll want to loop over the addresses from the table like you did initially, and then update to wp user meta https://developer.ww.wp.xz.cn/reference/functions/update_user_meta/
For new users/addresses, you can try hooking to the “ethpress_login” hook (search for it in the gitlab repo).
Make sure you use a meta key that’s not in use already…
Big thanks for the translations, I’ll add then once I get a chance to update!