Simple Portal

Customization => Custom Coding => Topic started by: jjwinc on January 29, 2011, 07:08:24 AM

Title: Help Capturing Additional Info
Post by: jjwinc on January 29, 2011, 07:08:24 AM
One site that I have created can be used by members and non-members alike; and they would like me to add a block to the landing page that can quickly gather the users email address and/or cellular number to be used to inform them of site updates via email/text.  I've done quite a bit of searching here and on SMF, but either I'm searching for the wrong terms, or it just doesn't exist as a mod or block.

Is there a way to add a text box or two along with a submit button that would capture the information to a new table and/or email the information to a particular address?  I know the functionality is at the core of SMF/SP, but how do we leverage that functionality for custom use?

Are there maybe wiki's on how to create a db table and manipulate the information via a block or custom code?  Any help or direction would be greatly appreciated.
Title: Re: Help Capturing Additional Info
Post by: AngelinaBelle on February 10, 2011, 12:40:57 PM
You can certainly use custom profile fields to hold additional member information.
After that, you'd have to write some code to actually make use of that information.

But you have website followers who DO NOT WANT TO REGISTER but WANT you to send them email and text? So anybody can just enter an email or phone # and get your updates sent to, well, anybody in the world?  You want an email list for that.  You aren't going to find that at SMF, but there are plenty of free ones out there, at least for email.

Once you've got it working, you can even put it in a SimplePortal block.
Title: Re: Help Capturing Additional Info
Post by: jjwinc on February 14, 2011, 10:16:12 AM
Thank you for the reply.  Yes, that's exactly what they want.  The site is a transit union website and they want to be able to capture both union members and riders (i.e.; customers) email addresses and/or cell numbers for "call to action" type blasts.  I tried leading them in the direction of twitter (because that's what twitter does best), but they want this instead <shrug>.

I know SMF (and SP) both use sendmail.  Would it be possible to mock up a simple HTML form with the PHP code to send the results via sendmail?  Has anyone ever done this?  For example, I see the following code in ManageMembers.php (this particular block is for sending email for activated users):

$replacements = array(
'USERNAME' => $member['name'],
'ACTIVATIONLINK' => $scripturl . '?action=activate;u=' . $member['id'] . ';code=' . $validation_code,
'ACTIVATIONLINKWITHOUTCODE' => $scripturl . '?action=activate;u=' . $member['id'],
'ACTIVATIONCODE' => $validation_code,
);

$emaildata = loadEmailTemplate('admin_approve_activation', $replacements, $member['language']);
sendmail($member['email'], $emaildata['subject'], $emaildata['body'], null, null, false, 0);
}
}


Obviously, I'm most interested in the sendmail line at the end.  What would I need to change in order to use my form blocks instead of pulling from the db?  Is this just standard PHP sendmail?  Can I just google it for examples or are there special rules to follow?



Title: Re: Help Capturing Additional Info
Post by: AngelinaBelle on February 14, 2011, 11:24:50 AM
Did you say you wanted to be able to send email to people who are not registered members of the forum?
Title: Re: Help Capturing Additional Info
Post by: jjwinc on February 14, 2011, 01:05:33 PM
Actually, we're simply gathering email addresses and/or cell phone numbers for the purposes of email blasts.  So I'm not interested in storing this information in a database anywhere, I simply want to take the contents of the message that is generated and mail it off to someone who is building a mailing list.

Title: Re: Help Capturing Additional Info
Post by: jjwinc on February 14, 2011, 01:07:25 PM
I realized that I didn't answer your question.  Yes, we are interested, ultimately, in capturing members and non-members email addresses and/or cell phone numbers for the purposes of sending them out notices.  BUT, we're not looking to email non-members from within SMF/SP, but rather send their name/cell to another email address so they can manually build a mailing list.
Title: Re: Help Capturing Additional Info
Post by: AngelinaBelle on February 14, 2011, 01:37:31 PM
Have you considered free mailing list software like Subscribe Me Lite, and other similar packages?
You install the cgi, you put a tiny (two-line )form in a block on your portal, the email list just works.
Very little hassle for you -- nothing to build.
Title: Re: Help Capturing Additional Info
Post by: jjwinc on February 18, 2011, 02:51:54 PM
Just wanted to give an update here.  I ended up going with NateMail, which just takes the information from a form and mails it to an address of your choosing.  I picked NateMail because it's a little more secure than other mail programs. 

The only thing I can not seem to do cleanly is have the "thank you" redirect page show up inside of the block that called the mail script.  Is this even possible? 

Even still, it's working perfectly, I just have the redirect link back to the main page and all
Title: Re: Help Capturing Additional Info
Post by: AngelinaBelle on February 18, 2011, 03:21:28 PM
Having the redirect show up in the same block would be awfully tricky, when you think about it, if you are passing the login information to an external CGI.

If it is just a generic "thank-you" page, I suppose that would be possible -- if you can tell your email software a specific URL, the block code could look for an extra parameter in the URL and decide to show the thank-you page.
Your solution gets you 80% of the way there, though, and is easier.
Title: Re: Help Capturing Additional Info
Post by: jjwinc on February 18, 2011, 04:44:09 PM
I suppose I will tackle that when I have a bit more time.  80% there plus the path of least resistance equals a happy man (at least for me).      :)

Thank you for the help.  As always, it's greatly appreciated.
EhPortal 1.39.8 © 2024, WebDev