0

I want to make a column in user list page from admin panel. And the column value will appear with the link like user edit option or I want to make a link with edit, view user option. initially, I made a column but I can't print the value.

the code below

   function my_custom_column($columns) {
    return array_merge( $columns, 
              array('link' => __('Link')) 
            );
}
// Now we add some content to each row by using 'manage_users_custom_column' hook
function my_custom_column_value($column_name, $user_id) {
        if ( 'link' == $column_name ) {
                echo '<a link="https://user/edit.com">edit user</a>';
            }

}
// Hook into filter
add_filter( 'manage_users_columns', 'my_custom_column' );
add_action( 'manage_users_custom_column', 'my_custom_column_value', 10, 2 );

The link will appear with user id cause this link data is individual for every user so if user id 1 he will go to the link with his user id or if 2 then he will go to the same page but two data is different.

Please help me to do it. Thanks I am new to WordPress.

0

Few notes:

  • manage_users_custom_column is a filter that returns the output.
  • Checkout the correct input arguments for the manage_users_custom_column filter.
  • Checkout get_edit_user_link() for the edit user url.
  • You might need to add a relevant capability check, as not all users can edit users.
  • It's useful to look at how the current user list table displays the user edit link.
  • i don't want to go for edit user link. i just want to go another edit page with individual user but same edit page – Arman Jun 24 '18 at 6:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.