Solved

add in php code to functions.php page

Posted on 2011-09-06
11
366 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
 

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
The purpose of this video is to demonstrate how to set up basic WordPress SEO. This will be demonstrated using a Windows 8 PC. The plugin used will be WordPress SEO by Yoast. Go to your WordPress login page. This will look like the following: myw…
The viewer will learn how to count occurrences of each item in an array.

707 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

14 Experts available now in Live!

Get 1:1 Help Now