• 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.

    • This topic was modified 8 years, 7 months ago by newspace.
Viewing 1 replies (of 1 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    Hi,

    After adding this code to a new snippet, you should be able to insert the [welcome_message] shortcode into the content of your page, and it should display properly.

Viewing 1 replies (of 1 total)

The topic ‘[welcome_message]?’ is closed to new replies.