Solved

General Question..

Posted on 2006-07-16
5
232 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

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

Title # Comments Views Activity
Woocommerce hooks for "Proceed To Checkout" and "Place Order" buttons ? 7 135
jQuery detect if it is a mobile device 3 95
Sort Multidimensional Array 11 34
WordPress syntax 2 25
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

911 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

25 Experts available now in Live!

Get 1:1 Help Now