Tutorial for plugin ?

By Djulia - September 8, 2010

This functions perfectly for me.

addFilter('record_saved_message', '_custom_record_saved_message', null, 1);

function _custom_record_saved_message($record_saved_message) {
return "Record saved ! Email sent !";
}

Djulia

Re: [Djulia] Tutorial for plugin ?

When did you call it? Did you have to save the record to get the message? I've added a link to the list so the message is a response to a click on the link not a save.
Graphic Lingoes
www.graphiclingoes.com

Re: [Djulia] Tutorial for plugin ?

By Chris - September 8, 2010

Hi folks,

It is thoroughly awesome that you two are working together and writing plugins!

It seems like you two have everything figured out already!

@GraphicLingoes: Using 'admin_head' instead of 'viewer_postinit' might be safer, since it's the closest hook before the call to displayAlertsAndNotices() in lib/menus/header.php

If you are super curious, you could try to figure out when and why your notice was getting cleared by either dumping out a backtrace from clearAlertsAndNotices(), or adding a trace lines before each call to it. Of course, that's not really going to help you solve the problem any better, maybe just understand why you had to solve it. ;)


Please let me know if either of you have any questions and keep up the great work! :D
All the best,
Chris

Re: [chris] Tutorial for plugin ?

By GraphicLingoes - September 8, 2010 - edited: September 9, 2010

Hi Chris,
thanks for the suggestion ("admin_head"). I've updated my code. I actually tried that earlier before I really understood the difference between addFilter and addAction and I kept getting wierd results because I wasn't returning anything with addFilter. Works perfectly now, thanks!
Graphic Lingoes
www.graphiclingoes.com

By GraphicLingoes - September 9, 2010 - edited: October 14, 2010

#######################################################################
NOTE: There is a newer version of the plugin available on the second page of this post.
Updated post 10/14/2010
#######################################################################

Hello everyone,

I've attached the final version for the first round of the Email New Account Activated plugin that I build with the help of CMSB staff and @Djulia. I hope you find it useful. So what does this plugin do? What it does is add a link to the "accounts" list labeled "email account activated" for admin users only. When you click on that link a pre-formatted email from the plugin code is sent to email address of the line in the list of records you clicked on.

The reason I built this plugin was I'm using the "Membership Plugin" from CMSB which I have customized a little for a client. My client did not want accounts to be active until they had a chance to review who they were and approve them. So what I did was add a check box to the accounts section called "Active" that is defaulted to unchecked which is inactive. It's a simple concept, when my client checks off the box the account becomes active. I then added some code to each member page to check if they are active or not. If not the member is re-directed to a page explaining that they are not active yet. I know there is some overhead that gets added with this check on every page, but the client wanted to be able to lock someone out of their member section in real time so I had to do it.

So when my client reviews the new member and checks off the box that they are active, of course, they wanted an easy way to notify the client that they are active. This is how the plugin was born. They said to me, "Mike it would be great if we could have a link right here that allowed us to click once to send a template email to the client and be done with it". Being the pepole pleaser that I am I had to say yes and now we have a new plugin.

Enjoy!
Mike


TIPS:
- You can specify what list the link shows in in the "gl_ena_addLink" function.
- You can change the $message variable for the email to say whatever you want, but if you are not familiar with how concatenation works you may want to read up on it here first http://www.w3schools.com/PHP/php_string.asp
- The "notice($message) function will change the blue alert that displays after the email is sent to say whatever you want so you could for example put "notice("Your alert text here")".
Graphic Lingoes
www.graphiclingoes.com

Re: [Djulia] Tutorial for plugin ?

@Djulia the plugin is public now see forum for more info. Thanks again for your help.

All the best, Mike.
Graphic Lingoes
www.graphiclingoes.com

Re: [Djulia] Tutorial for plugin ?

@Djuila I have an idea for how to make your suggestion work. I'll work on it today and upload the updated code later.

-
Graphic Lingoes
www.graphiclingoes.com

Re: [Djulia] Tutorial for plugin ?

By GraphicLingoes - September 10, 2010 - edited: September 10, 2010

Hi @Djuila,

Attached to this post is version 1.01 of the email new acount activated link plugin.

Changes:
Added code to plugin to check account to see if "email sent" field is true. If it is true the link is greyed out in the list and not clickable. NOTE: there is code in the comments on how to hide link completely if you need to.

Requirements:
To make this function work you must add a checkbox field to your accounts section called "activation_email_sent" If you type "Activation Email Sent" in the section editor it will create the "activation_email_sent" field name for you.

Hope this works for you!
Mike
Graphic Lingoes
www.graphiclingoes.com

By Chris - September 10, 2010

Awesome! :D
All the best,
Chris