I found the following code online, but it obviously needs correcting. Could anyone help me modify it accordingly? (assuming this code is remotely the right one). Thanks!
function new_contact_methods( $contactmethods ) {
$contactmethods[‘url’] = ‘Pro’;
return $contactmethods;
}
add_filter( ‘user_contactmethods’, ‘new_contact_methods’, 10, 1 );
function new_modify_user_table( $column ) {
$column[‘url’] = ‘Pro’;
return $column;
}
add_filter( ‘manage_users_columns’, ‘new_modify_user_table’ );
function new_modify_user_table_row( $val, $column_name, $user_id ) {
switch ($column_name) {
case ‘url’ :
return get_the_author_meta( ‘url’, $user_id );
break;
default:
}
return $val;
}
add_filter( ‘manage_users_custom_column’, ‘new_modify_user_table_row’, 10, 3 );
[Moderator note: code fixed. Please wrap code in the backtick character or use the code button.]
]]>In manage_users_custom_column, the case is the column slug you assigned in manage_users_columns. The return value will be the website URL from the user’s WP_User object. Get the user object with $user = get_user($user_id);
The URL will then be $user->user_url.
Note that all the quotes in your example are the improper “curly” style. They all need to be changed to the “straight” style.
]]>