Solved

General Question..

Posted on 2006-07-16
5
248 Views
Last Modified: 2012-05-05
<?php
$author = "<?php the_author_email() ?>";
?>
<div class="<?php if ($author->the_author_email == "email1@gmail.com") echo 'christopher_comment'; else if ($author->the_author_email =="email2@gmail.com") echo 'christine_comment'; ?>"><?php } ?>

This should echo either christopher_comment or christine_comment inot the class="" but it's not...

What is happening is this..
<div class="">      


Now.. how could I just check to see if $author is holding the correct email value.. and also.. does anybody see anything wrong with my statements?
0
Comment
Question by:cstormer
  • 3
  • 2
5 Comments
 
LVL 35

Expert Comment

by:Raynard7
ID: 17118657
Your tags look confused - for example if you are trying to put the author into a php value - using a function the_author_email() then you would do


<?php
$author = the_author_email();
?>


Also = author does not look like a class - so the_author_email does not look like a property, I wold try

<div class="<?php if ($author == "email1@gmail.com") echo 'christopher_comment'; else if ($author =="email2@gmail.com") echo 'christine_comment'; else echo $author; ?>">

But it is better form to actually put the php value in a php block rather than in the middle of html. ie

<?php
$author = the_author_email();

if ($author == "email1@gmail.com") {
    $classVal =  'christopher_comment';
} else if ($author =="email2@gmail.com") {
    $classVal =  'christine_comment';
} else {
    $classVal = $author;
} // end if
?>

<div class="<?php echo $classVal; ?>">

0
 

Author Comment

by:cstormer
ID: 17118862
This seems to be a something tha twould work... except the

<?php
$author = the_author_email();
?>

Seems to be echoing the value of the_author_email to the screeen...

0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17118877
the_author_email must be a function that you have defined, what you should do is remove any echo commands in this function, or change them to echo or not depending if you send true or false to the function.

ie

function the_author_email($boolVal) {
  if($boolVal) {
     echo $authorString;
  }
  return $authorString;
}
0
 

Author Comment

by:cstormer
ID: 17118889
the problem is the_author_email is a fucntion defined by wordpress (blogging software) it is hardwired into the code, changing it will change a ton of stuff... so I do know that it knows the correct value.. but I need to store the value it will echo out.. into a variable..

is there a way to take what it would echo (the email) and add it to a variable.. because if the code it produces prints the email to the screen... any thoughts?

0
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17119015
Without changing it I think it would be difficult.

However - one quick and easy work around would be to surround the code that calls it in html comment tags.

ie

<!--<?php
$author = the_author_email();
?>-->

Which means it will be output would be sent to the browser but as it would be commented it would not display
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

Suggested Solutions

Title # Comments Views Activity
Dynamic Dropdowns 15 32
Why will this INSERT statement not insert the date? 2 21
php help 34 58
Checking https returns 301 21 29
This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

830 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