Results 1 to 6 of 6

Thread: Welcome User / Welcome Guest Function (Mini-Hack)

  1. #1
    Thread Starter
    jobortunity's Avatar
    Join Date
    Oct 2011
    Location
    Kitchener, Ontario
    Posts
    153
    Thanks
    11
    Thanked 11 Times in 9 Posts

    Welcome User / Welcome Guest Function (Mini-Hack)

    This is a mini mod I came across while working on my child theme. I was looking to make my website more interactive, and so I needed a solution for when a guest visits the website, he would be greeted. Same concept goes for logged in users.

    After searching on Google for a quick solution, I came across this article on the Wordpress Forum: http://wordpress.org/support/topic/e...logged-in-user

    Turns out, there's already such a function. Unfortunately when trying it out on my JobRoller Theme, nothing happened. It just echo'd Welcome Guest when I was logged in. After looking at the script closer, I realized that a small modification was needed. So 2 min later, the mod was done, reloaded the page, and it works! Thought I would share this with you guys if you're ever looking to do this.

    Here's the Original Script (Works on Wordpress Blogs):

    Code:
    <?php global $user_nickname; get_currentuserinfo(); if ( $user_nickname<> "" ) { ?><?php echo $user_nickname ?><?php } else { ?>Welcome Guest<?php } ?>

    Here's My Script (Works on JobRoller):
    Code:
    <?php global $userdata; get_currentuserinfo(); if ( $userdata<> "" ) { ?>Welcome <?php echo $userdata->user_login; ?><?php } else { ?>Welcome Guest<?php } ?>

    So yeah, you can stick this pretty much anywhere on your website, header, sidebar, footer, pages etc. If you want to style it up, just wrap it with a div container or span container and style it up with css or just do what I do, stick it inside an h2 tag. lol.. Lazy bastard, I know..

    Hope you find it useful in your projects.

    Good Day.

    -Alex

  2. #2
    jomarkosabel's Avatar
    Join Date
    Mar 2009
    Location
    Philippines
    Posts
    40,958
    Thanks
    169
    Thanked 3,405 Times in 3,276 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!
    Please help our moderating team work more efficiently by not sending us support questions via PM. You can read more about how AppThemes support works here. However, you can send a PM to follow up and remind me if I missed your support request/thread.

    Thank you and have a nice day.

  3. #3
    tinygiantstudios's Avatar
    Join Date
    Jan 2011
    Posts
    1,607
    Thanks
    31
    Thanked 157 Times in 148 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!


  4. #4
    Thread Starter
    jobortunity's Avatar
    Join Date
    Oct 2011
    Location
    Kitchener, Ontario
    Posts
    153
    Thanks
    11
    Thanked 11 Times in 9 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  5. #5
    spartac's Avatar
    Join Date
    May 2011
    Posts
    7,171
    Thanks
    75
    Thanked 830 Times in 808 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

  6. #6
    Thread Starter
    jobortunity's Avatar
    Join Date
    Oct 2011
    Location
    Kitchener, Ontario
    Posts
    153
    Thanks
    11
    Thanked 11 Times in 9 Posts
    You must be an AppThemes customer and logged in to view this response. Join today!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] PROBLEM: Warning: call_user_func_array() [function.call-user-func-array]
    By ebardhi in forum Report ClassiPress Bugs
    Replies: 5
    Last Post: May 20th, 2011, 07:36 AM
  2. Guest Posts without registration?
    By mcasdorph in forum Help Using ClassiPress
    Replies: 4
    Last Post: April 25th, 2010, 05:36 PM