set membership signup to default to "disabled"
39 posts by 6 authors in: Forums > CMS Builder: Plugins & Add-ons
Last Post: July 19, 2012 (RSS)
By Jason - May 17, 2010
It treats everything between the __TEXT__ lines as plain text that is assigned to a variable.
Hope this helps.
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] set membership signup to default to "disabled"
By gkornbluth - May 17, 2010
So, it's a PHP thing not an e-mail thing.
Thanks,
Jerry
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By kdub718 - July 17, 2012
Re: [kdub718] set membership signup to default to "disabled"
By gkornbluth - July 17, 2012
Here's a recipe from my CMSB Cookbook thecmsbcookbook.com that explains how to use it and a link to the revised plugin.
Hope it helps.
Jerry Kornbluth
IMPLEMENTING THE (CORRECTED) EMAILONAPPROVED PLUGIN WITH THE WEBSITE MEMBERSHIP PLUGIN (ENCRYPTED PASSWORDS)
When a prospective member filled out the membership application, I wanted their application to be approved manually. I wanted an e-mail to be sent stating that their application had been received and that as soon as it was processed they would get a second “welcome” e-mail with their username and a temporary password.
NOTE: IMPLEMENTING THE CHANGES OUTLINED IN THIS RECIPE WILL ALLOW THIS PLUGIN TO WORK CORRECTLY WITH ENCRYPTED PASSWORDS (CMSB VERSION 2.08+ AND THE WEBSITE MEMBERSHIP PLUGIN V1.05+).
NOTE: Thanks to Steve from MustBeOnLine.com for discovering a coding error in the zipped plugin (now fixed). He discovered that there was a double $mail= in the line of code:
$errors = $errors=mail($_REQUEST['email'],"Your membership has been approve!",$message,$headers);,
It should be:
$errors = mail($_REQUEST['email'],"Your membership has been approve!",$message,$headers);,
Download and install the emailOnApproved plugin. You can download my modified (and corrected) version here:
http://www.thecmsbcookbook.com/downloads/emailOnApproved.zip
This modified plugin will allow you to set up a manual approval process and send an e-mail to your new members when they are approved.
Before encrypted passwords it was easier to email login credentials to a member after their account had been manually approved. (Their application was approved, their payment had been verified, etc.)
Since the implementation of encrypted passwords, the process became a bit more involved.
Here’s are the steps necessary:
First, create a visible password text field in the “Accounts” section (I call it visible_password in this recipe)
Then have your signup form automatically fill the visible_password field with the automatically generated password before it’s encrypted.
You’ll need to comment out (or remove) the send email instructions in the signup form
You’ll also want to change the “show thanks” message that is presented on a successful signup.
Then in the emailOnApproved plugin, you’ll want to change the ‘password’ field to ‘visible_password’
Here are the specifics:
First add a text field called visible_password to your “accounts” section. (You can call it anything you want to, but be consistent)
Then open your signup form and somewhere in the mysql_query("INSERT INTO `{$TABLE_PREFIX}accounts` SET code insert the following code as a separate line:
visible_password = '$password',
it doesn’t matter where in the series you insert the line, as long as it’s a separate line.
Next search for // send message and comment out the entire section with a after the section like this:
Just under that section of code you should find the section called // show thanks
You’ll want to modify that message to something like:
$errorsAndAlerts = "Thanks, We've created an account for you. As soon as you're approved we'll email you your password.\n";
$errorsAndAlerts .= "If you don't receive an email from us within a few minutes check your spam filter for messages from {$SETTINGS['adminEmail']}.\n";
// $errorsAndAlerts .= "<a href='{$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL']}'>Click here to login</a>.";
Notice that I’ve removed the reference to {$emailHeaders['from']} in the “spam filter” text and replaced it with {$SETTINGS['adminEmail']} (you’ll get an error if you don’t because you removed the original variable in the previous step) , and commented out the login URL line with a double forward slash (you can remove this line if you’d prefer).
Now save your signup form and open the emailOn Approved plugin.
The instructions on how to implement this plugin are below.
Search for ‘password’ and replace this with ‘visible_password’ (unless you called your field something else)
That’s it.
______________________________________________________
______________________________________________________
LEGACY INFORMATION
BACKGROUND
When I first activated the original emailOnApproved plugin, I was getting Undefined index errors reported on saving a record until I added this line suggested by Dave Edis to the error checking section of the code:
if ($Table name != 'accounts') { return; }
So now the error checking section looks like
// error checking
if ($tableName != 'accounts') { return; }
if (!array_key_exists($fieldname, $CURRENT_USER)) {
die(__FUNCTION__ .": You must create an accounts fields called '$fieldname'!");
}
And there are no more Undefined index errors.
I decided that it would make more sense to include the new member’s username, temporary password and a login URL in this email, so I modified the original:
// send email
$wasChecked = intval(!$oldRecord[$fieldname] && $_REQUEST[$fieldname]);
$wasUnchecked = intval($oldRecord[$fieldname] && !$_REQUEST[$fieldname]);
if ($wasChecked) {
$errors = sendMessage(array(
'from' => $SETTINGS['adminEmail'],
'to' => $_REQUEST['email'],
'subject' => "You have been approved!",
'text' => "Congradulations!
You have been approved for our website.
Your password is: {$_REQUEST['password']}
See you soon!
",
));
if ($errors) { die($errors); }
}
}
?>
To this:
NOTE: Make sure that there are no spaces after the $message=<<< __TEXT__ and that the __TEXT__; is flush against the left margin or you’ll generate errors.
// send email
$wasChecked = intval(!$oldRecord[$fieldname] && $_REQUEST[$fieldname]);
$wasUnchecked = intval($oldRecord[$fieldname] && !$_REQUEST[$fieldname]);
$message=<<< __TEXT__
Congratulations!
Your subscription has been processed successfully and you now have access to the "Members Only" area of our web site.
Your user name is: {$_REQUEST['username']}
and your temporary password is: {$_REQUEST['password']}.
Once you have successfully logged in, you can change your password and update your profile information.
<a href="http://www.your_web_site_URL.com{$GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL']}">Click here to login</a>
Best,
The Subscription Committee
__TEXT__;
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .="FROM:". $SETTINGS['adminEmail'];
if ($wasChecked) {
$errors = $errors=mail($_REQUEST['email'],"Your membership has been processed!",$message,$headers);
if ($errors!=1) { die("Mail Error: $php_errormsg"); }
}
}
?>
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By kdub718 - July 17, 2012
Do you have any ideas on how I could have an email sent to the site admin when a new user signs up?
Re: [kdub718] set membership signup to default to "disabled"
By gkornbluth - July 17, 2012
There's a plugin called alert record saved that could give you some ideas.
Search for alert record saved, all words on the forum and see how far you can get.
Best,
Jerry Kornbluth
Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php
By kdub718 - July 17, 2012
using this:
'to' => $SETTINGS['adminEmail'],
instead of the $Request ['email'] version.
then obviously modifying the email part accordingly. I haven't tried it yet but I don't see why it wouldn't work... I just don't know if it would be bad practice to do it that way or if I'm overlooking something
Re: [kdub718] set membership signup to default to "disabled"
By kdub718 - July 19, 2012 - edited: July 19, 2012
"Notice: Undefined index: fullname in /home/content/html/admin/plugins/websiteMembership/emails/user-new-signup.php on line 46"
So this is the user-new-signup.php
<?php
// load viewer library
$libraryPath = 'cmsAdmin/lib/viewer_functions.php';
$dirsToCheck = array('/home/content/html/','','../','../../','../../../');
foreach ($dirsToCheck as $dir) { if (@include_once("$dir$libraryPath")) { break; }}
if (!function_exists('getRecords')) { die("Couldn't load viewer library, check filepath in sourcecode."); }
if (!@$GLOBALS['WEBSITE_MEMBERSHIP_PLUGIN']) { die("You must activate the Website Membership plugin before you can access this page."); }
// Override email headers - uncomment these to override the values set by the calling program
global $SETTINGS, $FROM, $TO, $SUBJECT, $PLACEHOLDERS;
$FROM = $SETTINGS['adminEmail'];
//$TO = $SETTINGS['adminEmail']; // set by program
$SUBJECT = "Re: Trade Account Approval";
// Preview Mode: Allow developers to view email template directly for easy editing
$isPreviewMode = isBeingRunDirectly();
if ($isPreviewMode) { // these values only show when previewing email template directly
$TO = "preview@example.com";
$PLACEHOLDERS = array();
$PLACEHOLDERS['username'] = 'testuser';
$PLACEHOLDERS['password'] = 'password123';
$PLACEHOLDERS['loginUrl'] = "#loginUrl";
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
<style type="text/css">
body, td { font-family: arial }
</style>
</head>
<body>
<?php
// developer preview mode: show email headers when viewing email template directly
if ($isPreviewMode) { emailTemplate_showPreviewHeader(); }
?>
Hi <?php echo htmlspecialchars($PLACEHOLDERS['fullname']) ?>, is requesting a trade account<br/><br/>
Thanks for signing up to <?php echo htmlspecialchars($_SERVER['HTTP_HOST']) ?>.<br/><br/>
Your username is: <?php echo htmlspecialchars($PLACEHOLDERS['fullname']) ?><br/>
Your password is: <?php echo htmlspecialchars($PLACEHOLDERS['password']) ?><br/><br/>
</body>
</html>
So do I have to call out what fields I want to use somewhere else?
Re: [kdub718] set membership signup to default to "disabled"
By Jason - July 19, 2012
In order for a placeholder to work on the email, you must make sure you pass it to the template when sending the email on your signup page.
for example:
$emailHeaders = emailTemplate_load(array(
'template' => websiteLogin_pluginDir() . "/$emailTemplate",
'subject' => '', // set in template
'from' => '', // set in template
'to' => $_REQUEST['email'],
'placeholders' => array(
'username' => array_key_exists('username', $_REQUEST) ? $_REQUEST['username'] : $_REQUEST['email'], // if using email as username then show that instead
'password' => $password,
'loginUrl' => "http://" . $_SERVER['HTTP_HOST'] . $GLOBALS['WEBSITE_LOGIN_LOGIN_FORM_URL'],
'fullname' => @$_REQUEST['fullname'],
),
));
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/