• Resolved sunrosea

    (@sunrosea)


    Hi!

    I’ve been trying really hard to make the edit-comments.php page display a filter to show comments by specific author only. I want this to be by input, and not a drop down list. Do any one have an idea of how I can make that happen?

    Here’s the code that works, but uses drop down list:

    add_action('restrict_manage_comments', 'author_filter_2');
    
    function author_filter_2() {
    
        $args = array('name' => 'user_id', 'show_option_all' => 'View all authors');
        if (isset($_GET['user_id'])) {
            $args['user_id'] = $_GET['user'];
        }
    	wp_dropdown_users($args);
    }

    thanks for any help!

Viewing 1 replies (of 1 total)
  • Thread Starter sunrosea

    (@sunrosea)

    The reason I wanted to do that is, if I have a lot of users, and only have a drop down list, then that drop down list will be quite huge. And so I thought it’d be better with an input field.
    Anyways, I figured it out if anyone else is interested.

    I did it like this in my functions.php file:

    add_action('restrict_manage_comments', 'author_filter_2');
    
    function author_filter_2() {
    echo '<input type="text" name="user_id" value=""/>';
    }
    
    add_action('pre_get_comments', 'before_comments');
    
    function before_comments($clauses){
    
    if(is_admin()&&isset($_GET['user_id'])){
    $user= get_userdatabylogin($_GET['user_id']);
    $clauses->query_vars['user_id'] = $user->ID;
    }
    return $clauses;
    }
Viewing 1 replies (of 1 total)
  • The topic ‘filtering edit-comments.php from text input’ is closed to new replies.