?
Solved

placing logout link in my functions.php file

Posted on 2011-09-06
6
Medium Priority
?
312 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 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
While Plesk offers many potential benefits to website administrators, including compatibility with Windows Server and other leading technologies, the company has also been working to differentiate it from other control panels for content management…
This video teaches users how to migrate an existing Wordpress website to a new domain.
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…
Suggested Courses
Course of the Month16 days, 9 hours left to enroll

864 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