Skip to content

Instantly share code, notes, and snippets.

@AladinDridi
Last active June 5, 2017 14:07
Show Gist options
  • Save AladinDridi/29df569529eb372bb21acafcbb1e6837 to your computer and use it in GitHub Desktop.
Save AladinDridi/29df569529eb372bb21acafcbb1e6837 to your computer and use it in GitHub Desktop.
display author name in widget wordpress
<?php if(is_home() || is_single()){
echo get_the_author($post->post_author);
echo '
<style>
.linklien{
border: 2px solid #444 ;
background-color:blue;
}
</style>
<p class="linklien">
<a href="localhost/wptest/messages/sentbox/">
Envoyez un message</a></p>' ;
} ?>
this working with plugin code php widget for wordpress
////
<div class="about-author-info">
<h3>A propos de l'auteur <small>Voir tous les cours par <?php the_author_posts_link(); ?></small></h3>
</div>
<div class="about-author-description">
<?php the_author_meta("description"); ?>
<a href="mailto:<?php the_author_email(); ?>">Contacter l'auteur de ce cours</a>
</div>///// 3rd solution
<div class="about-author-info">
<h3>A propos de l'auteur <small>Voir tous les cours par <?php the_author_posts_link(); ?></small></h3>
</div>
<div class="about-author-description">
<?php the_author_meta("description"); ?><br>
</div>
<br>
<div class="Sendemail">
<form method="POST">
<TEXTAREA name="Message" placeholder="contacter l'enseignant de ce cours" cols="20" rows="5"></TEXTAREA>
<br>
<Input type="SUBMIT" name="submit" value="Envoyer" align="center" style="margin-top:12px;"></input>
</div>
<?php
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'From: contact.schoolmania.net ' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$Message= $_POST['Message'];
$to =the_author_email();
$subject = 'Email ';
$body = "message d'un etudiant";
if ($_POST['submit']) {
if(mail($to, $subject, $Message.$body, $headers)) {
echo '<p>Merci pour votre email!</p>';
} else {
echo '<p>Oops! erreur , verifiez encore les champs .</p>';
}}?>
@AladinDridi
Copy link
Author

add_filter( 'comments_open', 'my_comments_open', 10, 2 );

function my_comments_open( $open, $post_id ) {

$post = get_post( $post_id );

if ( 'page' == $post->post_type )
	$open = false;

return $open;

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment