?
Solved

placing logout link in my functions.php file

Posted on 2011-09-06
6
Medium Priority
?
309 Views
Last Modified: 2012-05-12
I'm trying to insert a proper logout link inside my functions.php file in my wordpress site. However, what I have currently is not working. I have...
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() {

if ( is_user_logged_in() ) {
echo '<style type=\'text/css\'>
.headertext_b {
color: #FFFFFF;
font-weight: bold;
font-style: italic;
font-size: 16px;
font-family: Arial, Tahoma, Verdana;
text-shadow: #002838 1px 1px;
}
table.header_bkg {
border-spacing:0;
padding: 0;
color: #FFFFFF;
}
.inputtext {
width: 128px;
height: 18px;
text-align: left;
margin: 0;
border: 0px;
background-color:transparent;
}
.formsubmit {
width: 46px;
height: 20px;
cursor:pointer;
margin: 0;
border: 0;
}
td.bkg {
background: url(\'/images/logo/bottom-right2.png\') no-repeat left top;
border-spacing:0;
padding: 0;
color: #FFFFFF;
height: 110px;
width: 354px;
}
</style>
</head>
<body>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'center\'>
<tbody>
<TR>
<TD rowspan=2><a href=\'/\' title=\'Members Mix\'><img src=\'/images/logo/left.png\' border=\'0\' width=\'606\' height=\'150\'></a></TD>
<TD>';
echo '<a href=\'<?php echo wp_logout_url( home_url() ); ?>\' title=\'Logout\'>Logout</a>';
echo '<img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'354\' height=\'40\'></a></TD>
</TR>
<TR>
<TD class=\'bkg\'>&nbsp;</TD>
</tr>
</TABLE>';
} else {
echo '<style type=\'text/css\'>
.headertext_b {
color: #FFFFFF;
font-weight: bold;
font-style: italic;
font-size: 16px;
font-family: Arial, Tahoma, Verdana;
text-shadow: #002838 1px 1px;
}
table.header_bkg {
border-spacing:0;
padding: 0;
color: #FFFFFF;
}
.inputtext {
width: 128px;
height: 18px;
text-align: left;
margin: 0;
border: 0px;
background-color:transparent;
}
.formsubmit {
width: 50px;
height: 20px;
cursor:pointer;
margin: 0;
border: 0;
}
td.bkg {
background: url(\'/images/logo/bottom-right.png\') no-repeat left top;
border-spacing:0;
padding: 0;
color: #FFFFFF;
height: 110px;
width: 354px;
}
</style>
</head>
<body>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'center\'>
<tbody>
<form name=\'loginform\' id=\'loginform\' action=\'wp-login.php\' method=\'post\'>
<input type=\'hidden\' name=\'testcookie\' value=\'1\' />
<TR>
<TD rowspan=2><a href=\'/\' title=\'Members Mix\'><img src=\'/images/logo/left.png\' border=\'0\' width=\'606\' height=\'150\'></a></TD>
<TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'354\' height=\'40\'></a></TD>
</TR>
<TR>
<TD class=\'bkg\'>
<TABLE border=\'0\' cellpadding=\'0\' cellspacing=\'0\' align=\'left\'>
<tbody>
<TR>
<TD><div style=\'padding-top:42px;\'><input type=\'text\' name=\'log\' id=\'user_login\' class=\'inputtext\' value=\'\' tabindex=\'1\' /></div></TD>
<TD><img src=\'/images/spacer.gif\' border=\'0\' width=\'13\'></TD>
<TD><div style=\'padding-top:65px;padding-bottom:10px;\'><input type=\'password\' name=\'pwd\' id=\'user_pass\' class=\'inputtext\' value=\'\' tabindex=\'2\' /></div><a href=\'wp-login.php?action=lostpassword\' title=\'forgot your password? click here\'><img src=\'/images/spacer.gif\' border=\'0\' width=\'130\' height=\'16\'></a></TD>
<TD><div style=\'padding-top:42px;padding-left:10px;\'><input type=\'image\' src=\'/images/logo/submit-but.png\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
</TR>
<tbody>
</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}
}

What do I need to make that logout link work?

Open in new window

0
Comment
Question by:COwebmaster
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 36492517
What do you see when the page renders?
0
 

Author Comment

by:COwebmaster
ID: 36492535
I see the logout link but when I hover over it, it says:

www.membersmix.com/ <?php echo wp_logout_url(home_url()); ?>

then when I click on it, it gives a 404 error.  I must the opening and/or closing php brackets around the link wrong?
0
 
LVL 70

Accepted Solution

by:
Jason C. Levine earned 2000 total points
ID: 36492553
No, you're not really constructing it correctly.

Try this instead:

echo "<a href='". wp_logout_url( home_url() ) ."' title='Logout'>Logout</a>";




0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Closing Comment

by:COwebmaster
ID: 36492600
Perfect!  that worked.  thanks jason1178.
0
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 36492621
Yep.

Remember that this is already a php file with a bunch of echo commands.  So when you want to add something to this file, you don't need <?php ?> brackets.  Just the echo command and use concatenation (the .) to separate text from PHP variables/functions.
0
 

Author Comment

by:COwebmaster
ID: 36492630
ok, got it.  Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
The purpose of this video is to demonstrate how to set up the permalinks on a WordPress Website. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Go t…
The viewer will learn how to count occurrences of each item in an array.
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question