Solved

add in php code to functions.php page

Posted on 2011-09-06
11
379 Views
Last Modified: 2012-05-12
Hi there.  I need to add the following code to the script below (where that TD is located).

if ( is_user_logged_in() ) {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
} else {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
}

Any ideas experts?
functions.php file...

<?php
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() { 
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:#fff;
}
.formsubmit {
width: 46px;
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: 340px;
}
</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=\'620\' height=\'150\'></a></TD>
<TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' 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=\'15\'></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;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}
%>

Open in new window

0
Comment
Question by:COwebmaster
11 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 36490507
Not sure what your question is...
0
 

Accepted Solution

by:
COwebmaster earned 0 total points
ID: 36490562
If I add in that code into the script, but the graphics don't look right so I must be doing something wrong. I have it like this:
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() { 
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:#fff;
}
.formsubmit {
width: 46px;
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: 340px;
}
</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=\'620\' height=\'150\'></a></TD>
if ( is_user_logged_in() ) {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
} else {
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' 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=\'15\'></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;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}

Open in new window

0
 
LVL 27

Expert Comment

by:Lukasz Chmielewski
ID: 36490675
There were no php tags
//customize header
remove_action('genesis_header', 'genesis_do_header');
add_action('genesis_header', 'child_do_header');
function child_do_header() { 
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:#fff;
}
.formsubmit {
width: 46px;
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: 340px;
}
</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=\'620\' height=\'150\'></a></TD>
<?php
if ( is_user_logged_in() ) {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
} else {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
}
?>
</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=\'15\'></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;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}

Open in new window

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:COwebmaster
ID: 36490743
okay, I tried that but it appears that both images get displayed
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 36490782
If you're interested in learning how to use styles inside of your php, there is a very good theme that is meant to show people that want to learn to develop themes. The theme is named Oenology by Chip Bennett. It is very well documented and should give you a much better understanding or how it all works. Here is a link to his tutorial:
http://make.wordpress.org/themes/2011/01/05/themes-and-the-wp-settings-api/

If you just want to use it once and don't need to learn, just use some code provided by the experts here.
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 36490830
0
 

Author Comment

by:COwebmaster
ID: 36491049
thanks jeremyjared74.  Unfortunately, I'm not familiar enough yet with php but still learning :)

So, any tips on why the following script adds both images into the table?

<?php
if ( is_user_logged_in() ) {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
} else {
?>
    <TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' height=\'40\'></a></TD>
<?php
}
?>
0
 

Author Comment

by:COwebmaster
ID: 36491386
nevermind, I figured it out on my own.
//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:#fff;
}
.formsubmit {
width: 46px;
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: 340px;
}
</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=\'620\' height=\'150\'></a></TD>
<TD><a href=\'/join\' title=\'Logout\'><img src=\'/images/logo/top-right2.png\' border=\'0\' width=\'340\' 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=\'15\'></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;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</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:#fff;
}
.formsubmit {
width: 46px;
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: 340px;
}
</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=\'620\' height=\'150\'></a></TD>
<TD><a href=\'/join\' title=\'Join MembersMix.com!\'><img src=\'/images/logo/top-right.png\' border=\'0\' width=\'340\' 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=\'15\'></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;\'><input type=\'submit\' value=\'Log In\' name=\'wp-submit\' tabindex=\'3\' id=\'1\' /></div></TD>
	</TR>
	<tbody>
	</TABLE>
</TD>
</tr>
</form>
</TABLE>';
}
}

Open in new window

0
 

Author Closing Comment

by:COwebmaster
ID: 36518412
mine version worked
0
 
LVL 23

Expert Comment

by:jeremyjared74
ID: 36491885
I guess I didn't make it in time.

Here is a little bit of advice for you if your using php with WordPress, or any php site. It's best to use dynamic links when possible. For instance, with WordPress you can call for your images and link to text like this:
<a href="<?php echo get_permalink(1); ?>">join<img src="<?php bloginfo('template_url'); ?>/images/logo.jpg"/></a>

Open in new window

0
 

Author Comment

by:COwebmaster
ID: 36491903
Okay, thank you.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Recently I spent hours debugging an issue in a Rails project where ActiveRecord was causing MySQL errors trying to create a User object of a class at the top level of a Single Table Inheritance model structure.  It turns out `.create` behaves differ…
This article discusses how to create an extensible mechanism for linked drop downs.
The purpose of this video is to demonstrate how to update a WordPress Site’s version. WordPress releases new versions of its software frequently and it is important to update frequently in order to keep your site secure, and to get new WordPress…
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…

749 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