Username Shortcode Plugin

Welcome, Diyguy!
Logout

[diy_username] Wp default logout or login url text 70%

[diy_username users=" "] Use “login” “email” “firstname” “lastname” “level”

Login:

Email:

Firstname:

Lastname:

Level:

ID:

Welcome, diyguy!
Logout

Welcome, diyguy!
Logout

Use “login” “email” “firstname” “lastname” “level”

Login: diyguy

Email: guy@cheapasdiy.com

Firstname: Diy

Lastname: Guy

Level: 10

Shortcode

[diy_username] displays username login or logout with defaults

If logged in puts out html <div><p style=”font-size: 70%;”>Wellcome current_user !</br><a href=”wp_default_logout_url”>Logout</a></p></div>

if logged out html <div><p style=”font-size: 70%;”><a href=”wp_default_login_url”>Login</a></p></div>

Use one or all three [diy_username logouturl=" " loginturl=" " style=" "]

use style to change <p style=” “> [diy_username style="font-size: 200%;"]

Just Text No HTML

[diy_username users=" "] use “login” “email” “firstname” “lastname” “level” “id”

Free Download

<?php 
 /**
 Plugin Name: Cheapasdiy UserName Plugin
 Plugin URI: https://wp.cheapasdiy.com/username-shortcode-plugin/ 
 Description: Includes plugin for WP UserName. https://cheapasdiy.com/
 Version:     0.0.1
 Author:      Cheapasdiy
 Author URI:  https://cheapasdiy.com
 License:     None
 License URI: None
 **/ /**
 Shortcode [diy_username] displays username login or logout with defaults
 Use one or all three [diy_username logouturl="" loginturl="" style=""]
 [diy_username style="your code"] use style to change <p style=”font-size: 70%;”>
 or to return just text no html use
 [diy_username users=""] 
 use "login" "email" "firstname" "lastname" "level" 
  **/     function cheapasdiy_username_function($atts) { 
/**Add Your default Code here**/
 if($atts[users]) $usersT=true; else $usersT=false;
     $a = shortcode_atts( array(
 'users' =>  '',
 'logouturl' => wp_logout_url() ,
 'loginurl' => wp_login_url() ,
 'style' =>  'font-size: 70%;',    
     ), $atts );
 $current_user = wp_get_current_user();
 $default=$current_user->user_login;
 $Wel = "Welcome ";
 $Logouturl = esc_attr($a['logouturl']);
 $Loginurl = esc_attr($a['loginurl']);
 $Login = '<a href="'.$Loginurl.'">Login</a>';
 $Logout = '!</br><a href="'.$Logouturl.'">Logout</a>';
 $Ifuserin = '<div><p style="'.esc_attr($a['style']).'">'.$Wel.$current_user->user_login.$Logout.'</p></div>';
 $Ifuserout = '<div><p style="'.esc_attr($a['style']).'">'.$Login.'</p></div>';
     if (is_user_logged_in()) $Ifuser = $Ifuserin;
 else $Ifuser = $Ifuserout;
 switch (esc_attr($a['users'])) {
   case "login":
     $users=$current_user->user_login;
     break;
   case "email":
     $users=$current_user->user_email;
     break;
   case "level":
     $users=$current_user->user_level;
     bre‏k;
   case "firstname":
     $users=$current_user->user_firstname;
     break;
   case "lastname":
     $users=$current_user->user_lastname;
     break;
   case "id":
     $users=$current_user->user_ID;
     break;
   default:
     $users=$default;
 }
 if ($usersT==true) return $users;
 else return $Ifuser;        
 }
 /**Sets the Name of ShortCode [diy_username users="login"] and Calls the Function**/
     add_shortcode( 'diy_username', 'cheapasdiy_username_function' );
 ?>

Leave a Reply

Your email address will not be published. Required fields are marked *