0

As default the Users Screen in the Backend allows me to add, change, or delete my site's users:

enter image description here

Now i need a additional url in the user list, wich redirects me to each users front-end profile (e.g. www.mysite.com/author/anna/). I was not able to find anything in the wordpress codex or online. Any idea how to solve this problem?

0

The following will add a "View author profile" link to the row actions (i.e., the links that appear when you hover over the username):

add_filter ('user_row_actions', 'add_view_author_page', 10, 2) ;

function
add_view_author_page ($actions, $user)
{
    $href = esc_attr (get_author_posts_url ($user->ID)) ;
    $actions['add_view_author_page'] = "<a href='$href'>View author page</a>" ;

    return ($actions) ;
}

Edit:

Or if you prefer to have the link in column of the table, you could do:

add_filter ('manage_users_columns', 'users_columns') ;
add_filter ('manage_users_custom_column', 'users_custom_column', 10, 3) ;

function
users_columns ($cols)
{
    $cols['author_page'] = 'Author page' ;

    return ($cols) ;
}

function
users_custom_column ($default, $column_name, $user_id)
{
    if ('author_page' == $column_name) {
        $href = esc_attr (get_author_posts_url ($user_id)) ;
        $default .= "<a href='$href'>View</a>" ;
        }

    return ($default) ;
}
|improve this answer|||||
  • @Learningbydoing oops :-) Also, I just edited the answer to show how to do it as an additional column to the table...in case you'd prefer it that way (personally, I prefer things like this as a row action) – Paul 'Sparrow Hawk' Biron Mar 10 '17 at 22:27
  • Great - the second code has also the same error - pleas remove the bracket again :) Otherwise - just perfect! – Learning by doing Mar 10 '17 at 22:29
  • typing too fast – Paul 'Sparrow Hawk' Biron Mar 10 '17 at 22:31

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.