Method to add Sender Name and Sender Email to Tell-A-Friend feature

Register an Account
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old 11-18-2007, 01:36 PM
Pligg Donor
Pligg Version: 9.8.2
Pligg Template: custom
 
Join Date: Sep 2007
Location: King of Prussia, PA
Posts: 62
If you would like to have the user specify his name and email address when telling a friend about a story using the "Tell-A-Friend" form, here is how to do it:

In "recommend_small.tpl", add the code below after line 2 (after code "<form name="email_to" method="get" action="{$my_base_url}{$my_pligg_base}/recommend.php">"):
Code:
Enter your name:<br>
<input type="text" name="sender_name" size="35" id="sender_name{$link_shakebox_index}" value=""><br><br>
Enter your email address:<br>
<input type="text" name="sender_email" size="35" id="sender_email{$link_shakebox_index}" value=""><br><br>
In "recommend.php", add the code below after line 95 (after code "$headers .= "Bcc: " . $addresses[$i] . "\n"; } } }"):
Code:
$the_sender_name = $_REQUEST['sender_name'];
if (empty($the_sender_name)) {
	$cansend = -100;
	echo '<br>Error: You must include your name.<br>';
}
$the_sender_email = $_REQUEST['sender_email'];
if (!check_email_address($the_sender_email)) {
	$cansend = -100;
	echo '<br>Error: Your email address ' . $the_sender_email . ' is not a valid email address.<br>';
}
In "recommend.php", replace the code:
Code:
		if(isset($_REQUEST['email_message'])){
			$message = $_REQUEST['email_message'];
		} else {
			$message = Default_Message;
		}
		if ($current_user->user_login){
		$body = $message . "\r\n\r\n" . Included_Text_Part1 ." ". $current_user->user_login .",". Included_Text_Part2 ."\r\n\r\n".$link->title." - " .strip_tags($link->content)."\r\n\r\n" ."Here is a link to the story: ". $link_url;}
		else{
		$body = $message . "\r\n\r\n" . Included_Text_Part1 ." Anonymous,". Included_Text_Part2 ."\r\n\r\n".$link->title." - " .strip_tags($link->content)."\r\n\r\n" ."Here is a link to the story: ". $link_url;}
with the following code:
Code:
		$body = "Your friend ".$the_sender_name." (".$the_sender_email.") would like to share the story below with you";
		if(isset($_REQUEST['email_message'])){
			$body = $body . " and added this message for you: \r\n\r\n";
			$body = $body . $_REQUEST['email_message'] . " \r\n\r\n";
		} else {
			$body = $body . ". \r\n\r\n";		
		}
		$body = $body . "\r\n\r\n";
		$body = $body . "Story: ".$link->title." \r\n\r\n";
		$body = $body . strip_tags($link->content)."\r\n\r\n" ."Here is a link to the story: ". $link_url;
In js/xmlhttp.php, add the following code in the "emailto" function after the line "email_address = document.getElementById('email_address_1_' + htmlid).value;"
Code:
sender_name = document.getElementById('sender_name' + htmlid).value; 
sender_email = document.getElementById('sender_email' + htmlid).value;
In js/xmlhttp.php, change the line:
Code:
mycontent = "email_address=" + escape(email_address) + "&email_to_submit=submit&email_message=" + escape(email_message) + "&original_id=" + original_id + "&backup=0";
with the following line:
Code:
mycontent = "sender_name=" + escape(sender_name) + "&sender_email=" + escape(sender_email) +  "&email_address=" + escape(email_address) + "&email_to_submit=submit&email_message=" + escape(email_message) + "&original_id=" + original_id + "&backup=0";
Voila!!!
Reply With Quote
Reply

Thread Tools
Display Modes




Pligg Modules and Pligg Templates from Pligg Pro Find support on the Pligg CMS Forum - 24 hours a day! Make a donation to support Pligg CMS development