Skip to content

Instantly share code, notes, and snippets.

@webmaster007
Last active March 14, 2018 11:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save webmaster007/95569a5cbe049501a98c95f214181e36 to your computer and use it in GitHub Desktop.
Save webmaster007/95569a5cbe049501a98c95f214181e36 to your computer and use it in GitHub Desktop.
WP-Search-Username - Wordpress plugin - Description = Typ the username and find the author page from the author that you looking.
=== WP Search Username ===
Plugin name: WP Search Username
Plugin URI: https://www.wordpress.org/plugins/wp-search-username/
Version: 1.0
Author: Robin Grasmeijer
Donate link:
Tags: search, username, author, display name, posts, custom posts, products, category, wordpress, post
Requires at least: 3.5
Tested up to: 4.9
Stable tag: 2.3.4
Search every username from the author in your Wordpress site.
== Description ==
Search every username in your Wordpress site from the author. Make the WP Search Username Widget active in your Widgets menu from your Wordpress site.
Or place the below shortcode in your Wordpress site page content:
[search-username]
Or place the php shortcode in your themes file with a FTP Program. You can find the normal and php shortcode in your shortcodes.txt file.
Option author page with FTP:
Only if you have not a author.php page in your themes then you can upload the author.php page from your plugin directory with a FTP program and save it up your pc directory. And upload it to your themes /wp-content/themes/your-theme-name/ directory with a FTP Program.
== Installation ==
= Uploading in WordPress Dashboard =
1. Navigate to the 'Add New' in the plugins dashboard
2. Navigate to the 'Upload' area
3. Select `wp-search-username.zip` from your computer
4. Click 'Install Now'
5. Activate the plugin in the Plugin dashboard
= Using FTP =
1. Download `wp-search-username.zip`
2. Extract the `wp-search-username` directory to your computer
3. Upload the `wp-search-username` directory to the `/wp-content/plugins/` directory
4. Activate the plugin in the Plugin dashboard
== Screenshots ==
5 Screenshots in the assets directory.
== Changelog ==
== Upgrade Notice ==
= 1.0 =
Initial release
<?php
/*
* Template Name: Author Page Template
*/
?>
<?php get_header(); ?>
<div id="content" class="narrowcolumn">
<div class="wpsu">
<?php
if(isset($_GET['author_name'])) :
$curauth = get_userdatabylogin($author_name);
else :
$curauth = get_userdata(intval($author));
endif;
?>
<?php
$curauth = (get_query_var('author_name')) ? get_user_by('slug', get_query_var('author_name')) : get_userdata(get_query_var('author'));
?>
<?php
global $wp_query;
$curauth = $wp_query->get_queried_object();
?>
<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $_GET['author_name']) : get_userdata($_GET['author']);
?>
<?php
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
?>
<div class="author_bio">
<h2>About: <span><?php echo $curauth->first_name; ?> <?php echo $curauth->last_name; ?></span></h2>
<div class="floatLeft" style="margin-right: 10px"><?php echo get_avatar($curauth->ID, $size = '96'); ?></div>
<p>Website: <a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></p>
<p>Profile: <?php echo $curauth->user_description; ?></p><br>
<h2>Posts by <?php echo $curauth->nickname; ?>:</h2>
<ul>
<!-- The Loop -->
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<li>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link: <?php the_title(); ?>">
<?php the_title(); ?></a>,
<?php the_time('d M Y'); ?> in <?php the_category('&');?><br><br>
<div class="floatLeft" style="margin-right: 10px"><?php echo get_avatar($curauth->ID, $size = '96'); ?></div>
<p>Website: <a href="<?php echo $curauth->user_url; ?>"><?php echo $curauth->user_url; ?></a></p>
</li>
<?php endwhile; else: ?>
<p><?php _e('No posts by this author.'); ?></p>
<?php endif; ?>
<!-- End Loop -->
</ul>
</div>
</div>
</div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
=== WP Search Username ===
Plugin name: WP Search Username
Plugin URI: https://www.wordpress.org/plugins/wp-search-username/
Version: 1.0
Author: Robin Grasmeijer
Donate link:
Tags: search, username, author, display name, posts, custom posts, products, category, wordpress, post
Requires at least: 3.5
Tested up to: 4.9
Stable tag: 2.3.4
Search every username from the author in your Wordpress site.
== Description ==
You can place the below shortcode in your Wordpress site page content:
[search-username]
Or place the below php shortcode in your themes file with a FTP Program:
<?php
// Use shortcode in a PHP - WP Search Username echo do_shortcode( '[search-username]' );
?>
<?php
/*
Plugin Name: WP Search Username
Plugin URI: https://www.wordpress.org/plugins/wp-search-username/
Description: Find the username from the author in your WordPress site.
Version: 1.0
Author: Robin Grasmeijer
Author URI: http://wordpress.com/
Text Domain: WP Search Username
*/
add_action( 'wp_enqueue_scripts', 'wp_search_username_scripts' );
// use widgets_init action hook to execute custom function
add_action( 'widgets_init', 'wpsu_searchusernamewidget_register_widgets' );
//register our widget
// constructor
function wpsu_searchusernamewidget_register_widgets() {
register_widget( 'wpsu_searchusername_widget' );
}
//wpsu_searchusername_widget class
class wpsu_searchusername_widget extends WP_Widget {
//process the new wp search username widget
// new constructor
function __construct() {
$widget_ops = array(
'classname' => 'wpsu_searchusernamewidget_widget_class',
'description' => ' '
);
parent::__construct( 'wpsu_searchusername_widget', 'WP Search Username Widget', $widget_ops );
}
//build the wp search username widget settings form
function form($instance) {
$defaults = array( 'title' => 'Search Username' );
$instance = wp_parse_args( (array) $instance, $defaults );
$title = $instance['title'];
?>
<p>Title: <input class="widefat" name="<?php echo $this->get_field_name( 'title' ); ?>" type="text" value="<?php echo esc_attr( $title ); ?>" /></p>
<?php
}
//save the wp search username widget settings
function update($new_instance, $old_instance) {
$instance = $old_instance;
$instance['title'] = strip_tags( $new_instance['title'] );
return $instance;
}
//display wp search username the widget
function widget($args, $instance) {
extract($args);
echo $before_widget;
$title = apply_filters( 'widget_title', $instance['title'] );
if ( !empty( $title ) ) { echo $before_title . $title . $after_title; };
//display search username form
wpsu_search_form();
echo $after_widget;
}
}
add_action( 'pre_get_posts', 'wpsu_searchusername_query' );
//Builds the wp search username form
function wpsu_search_form(){
?>
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<label class="screen-reader-text" for="s"><h2><?php _x( 'Search Username', 'label' ); ?></h2></label>
<input type="text" id="author" name="q=author&author_name" value="" placeholder="Search for ...">
<input type="submit" value="Search" />
</form>
<?php
}
// WP Shortcode to display WP search username form on any page or post.
function wpsu_form_creation(){
?>
<form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>"><br>
<label class="screen-reader-text" for="s">Search Username: </label>
<input type="text" id="author" name="q=author&author_name" value="" placeholder="Search for ...">
<input type="submit" value="Search" />
</form><br>
<?php
}
add_shortcode('search-username', 'wpsu_form_creation');
@webmaster007
Copy link
Author

This is my plugin 'wp-search-username'. Make a directory 'wp-search-username' and add the files in the directory 'wp-search-username'. And upload it to your plugin directory from your Wordpress site. And make it activate. You can find the author page from every user if you type the username from a author.

@webmaster007
Copy link
Author

screenshot-1
screenshot-2
screenshot-3
screenshot-4
screenshot-5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment