Solved

placing logout link in my functions.php file

Posted on 2011-09-06
6
305 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
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 

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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

This article discusses four methods for overlaying images in a container on a web page
FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
The purpose of this video is to demonstrate how to manually back up a WordPress Database. This will be demonstrated using a Windows 8 PC. The Host used will be IPage.com Log into your Hosting account. IPage will be used for demonstration : Locat…
The purpose of this video is to demonstrate how to integrate Mailchimp with WordPress, by placing a Mailchimp signup form on a WordPress Page or Post. This will be demonstrated using a Windows 8 PC. Mailchimp will be used. Log into your Mailchi…

816 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

8 Experts available now in Live!

Get 1:1 Help Now