Forums

[resolved] Add a link to user-table in admin area? (2 posts)

  1. jl2424
    Member
    Posted 1 year ago #

    In the admin area there is a table showing all existing blog users and authors (wp-admin/users.php). I need to add a link to each row of the table (i.e. for each user) with the title "Preview user" and linking the URL "author/user-name". How can I achieve this without hacking core?

  2. Mark / t31os
    Moderator
    Posted 1 year ago #

    Untested in 2.8/2.9, but this is tested as working on 3.0.1... :)

    // Intended to serve as an example only, modify the code to suit your requirement
    
    add_filter( 'manage_users_columns','new_users_column', 10, 1 );
    function new_users_column( $cols ) {
    	$cols['preview_foo'] = 'ChangeThisValue';
    	return $cols;
    }
    add_filter( 'manage_users_custom_column', 'new_users_column_data', 10, 3 );
    function new_users_column_data( $existing_string, $col_name, $user_object_userID ) {
    	if( 'preview_foo' != $col_name )
    		return $existing_string;
    	$preview = get_author_posts_url( $user_object_userID );
    	$name    = get_the_author_meta( 'user_login', $user_object_userID );
    	return "<a href='$preview'>$name</a>";
    }

    Hope that helps.. ;)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.