?
Solved

add in php code to functions.php page

Posted on 2011-09-06
11
Medium Priority
?
382 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Technology Partners: 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

There is a huge demand for CodeIgniter among the PHP web developers due to its dynamic features and benefits these days. It is one of most popular and agile open source PHP framework for creating robust web applications in PHP web development field.…
There are times when I have encountered the need to decompress a response from a PHP request. This is how it's done, but you must have control of the request and you can set the Accept-Encoding header.
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 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

765 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