Created
March 29, 2017 01:45
-
-
Save layoutph/f9f41407964f744ea2cd8da46ab54fa9 to your computer and use it in GitHub Desktop.
Woocommerce Greet Visitors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Setting up variable names | |
$current_user = wp_get_current_user(); | |
// Get current username | |
if ( !$current_user->user_firstname ) { $customername = $current_user->display_name; } | |
// No username, then use the default username. If you are the admin , then the display name is "admin" | |
if ( $current_user->user_firstname ) { $customername = $current_user->user_firstname; } | |
// If user has a profile name, then display name will be its Firstname | |
if ( $current_user->user_lastname ) { $customername = $customername . " " . $current_user->user_lastname; } | |
// If user has a first name and lastname, then customer name will use this format Firstname Lastname | |
?> | |
<?php if (!is_user_logged_in()) { ?> | |
<!-- Will display if a visitor is not login --> | |
Hello, Friend! Click here to login <a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" class="friendlink" >login</a> or <a href="<?php echo get_permalink( get_option('woocommerce_myaccount_page_id') ); ?>" class="friendlink" >create a free account</a>. It's sooo eezzee breezee! :)<br /><br /> | |
<?php } ?> | |
<?php if (is_user_logged_in()) { ?> | |
<!-- Will display the message below if the visitor is logged in | |
Will use the name format at the top. | |
--> | |
Welcome back, <?php echo $customername; ?> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment