最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

search - Find user by nicename and open profile

programmeradmin6浏览0评论

I want to add filter function and show user profile page by using search form. This is what I have now:

function test_where_filter($where){
    global $wpdb;
    if( is_search() ) {
        $search= get_query_var('s');
        $query=$wpdb->prepare("SELECT id FROM $wpdb->users WHERE ( meta_key='user_nicename' AND meta_value LIKE '%%%s%%' )", $search ,$search);
        $authorID= $wpdb->get_var( $query );

        if($authorID){
            ...
        }

    }
    return $where;
}

add_filter('posts_where','test_where_filter');

Is my code correct and how to open author page if it will be found? Not a search result page, but user page with this link: example/author/nicename? Thank's for any help with this!

发布评论

评论列表(0)

  1. 暂无评论