Solved

placing logout link in my functions.php file

Posted on 2011-09-06
6
304 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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

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…
In order to have all security and back ups taken care of, WordPress users can sign up for services with WP Engine.
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

919 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

18 Experts available now in Live!

Get 1:1 Help Now