Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter montana949

    (@montana949)

    Thanks t31os, I figured it out!

    I used a $var to hold the outcome of the funtions in seperate php tags. Then I echo’d the $var.

    <?php
    $logout = wp_logout_url(get_permalink());
    $username = wt_get_user_name();
    ?>
    
    <?php
      if (is_user_logged_in()){
               echo "Welcome, $username!<a href='https://blog.complimedia.com/wp-admin/'>Your Dashboard</a><a href='$logout' title='Log out of this account'>Log out</a>";
             }
             else {
               echo "Welcome, guest!";
               };
    ?>

    Also in case your wondering how I got the username I created the function with this code

    <?php function wt_get_user_name()
    {
    	global $userdata;
    	get_currentuserinfo();
    	return $userdata->user_login;
    } ?>
    Thread Starter montana949

    (@montana949)

    The first piece of code I used does _NOT_ work. Please see this thread: https://www.ads-software.com/support/topic/225695?replies=8

    Basically I want to echo out wp_logout_url(get_permalink()); but I don’t know how to do that in php! I’ve tried making that a variable and inserting the $var into the echo statement but that was unsuccessful as well.

    wt_get_user_name was found on this site: https://www.web-templates.nu/2008/08/27/get-user-name/

    once again I want to put that function in the echo statement.

    Thread Starter montana949

    (@montana949)

    Are you using wordpress 2.7.1? I get this error:

    You are attempting to log out of Complimedia Online Blog
    
    Please try again.

    How Can I add the correct logout link (<?php echo wp_logout_url(get_permalink()); ?>) inside the echo statement?

    I would also really like to check the registered users name and display it inside the echo statement but I do not know how.

    Something like this:

    if (is_user_logged_in()){
               echo "<h3>Welcome, wt_get_user_name();!</h3>
    
    <li><a href='wp_logout_url(get_permalink());' title='Log out of this account'>Log out</a></li>
    ";}

    montana949

    (@montana949)

    Can anyone help me out? I have an if statement checking if users are logged in and then showing them their a link to their dashboard and logout link. I cannot get the function to work in the echo statement though! I would like the logout link to log them out & redirect to the current page and have it also say Welcome, username! instead of Welcome, friend!

    Check out my code below:

    <?php   if (is_user_logged_in()){
               echo "<h3><span class='slash'>//</span>Welcome, Friend!</h3><br /><br /><li><a href='https://blog.complimedia.com/wp-admin/'>Your Dashboard</a></li><li><a href='/wp-login.php?action=logout' title='Log out of this account'>Log out</a></li>";}
             else {
               echo "<h3><span class='slash'>//</span>Welcome, guest!</h3><br /><br /><li><a href='/wp-login.php'>Sign In Here</a></li>";
               };
    ?>

    Thanks so much!

Viewing 4 replies - 1 through 4 (of 4 total)