Solved

placing logout link in my functions.php file

Posted on 2011-09-06
6
302 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
  • 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 500 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 Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 

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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
This article discusses four methods for overlaying images in a container on a web page
The purpose of this video is to demonstrate how to exclude a particular blog category from the main blog page. This is can be used when a category already has its own tab, or you simply want certain types of posts not to show up on the main blog. …
The purpose of this video is to demonstrate how to Import and export files in WordPress. 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 : Click on Too…

757 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now