Solved

General Question..

Posted on 2006-07-16
5
218 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Easy Project Management (No User Manual Required)

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
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 …

762 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

15 Experts available now in Live!

Get 1:1 Help Now