[welcome_message]?
-
Hello, I do not understand how to make it work, I use DIVI Builder. If I want this to appear on my home page, what is the short code I need to put in the page? This one: [welcome_message]?
Here is my code:// Create a welcome message shortcode
function d4tw_welcome_msg () {
$current_user = wp_get_current_user(); //get the current user info
if ( is_user_logged_in () && ( $current_user->user_firstname ) ) { //this will run if user is logged in and has a first name registered
return ‘<p>Welcome back ‘ . $current_user->user_firstname . ‘. Thank you for shopping!’; //return the message
}
elseif ( is_user_logged_in () && ( ! $current_user->user_firstname ) ) { //this will run if user is logged in with no first name registered
return ‘<p>Welcome back ‘ . $current_user->nickname . ‘. Thank you for shopping!’; //run the message
}
else {
return ‘Welcome, guest! Click here to create an account or login.’; //this will run for guest users
}
}
add_shortcode(‘welcome_message’, ‘d4tw_welcome_msg’);Thank you for answer.
The topic ‘[welcome_message]?’ is closed to new replies.