Last active
December 15, 2015 00:38
-
-
Save stevewithington/5174210 to your computer and use it in GitHub Desktop.
Easily add existing Mura CMS users to a Mailing List.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cfsilent> | |
<cfscript> | |
// MailingListBean (if you don't know the MLID, but you know the ListName) | |
mlid = $.getBean('mailinglistBean').loadBy( | |
name='Mailing List Name Goes Here' | |
, siteid=$.siteConfig('siteid') | |
).getMLID(); | |
//mlid = '6013C140-FD78-B5D9-60A468E7D2B5D6F0'; | |
if ( $.event('subscribe') == 'YES' ) { | |
$.currentUser('siteid',$.event('siteid')); | |
$.currentUser('isverified',1); | |
$.currentUser('mlid', mlid); | |
$.getBean('mailinglistManager').createMember($.currentUser().getAllValues()); | |
} | |
// Mailing List Manager | |
mlm = $.getBean('mailinglistManager'); | |
// Members RecordSet | |
rsMembers = mlm.getListMembers( | |
mlid=mlid | |
, siteid=$.event('siteid') | |
); | |
</cfscript> | |
</cfsilent> | |
<cfoutput> | |
<cfif not $.currentUser().isLoggedIn()> | |
<p><a href="#$.siteConfig('loginURL')#" class="btn btn-primary">LOGIN</a></p> | |
<cfelseif not listFindNoCase(valueList(rsMembers.email), $.currentUser('email'))> | |
<p><a class="btn btn-info" href="./?subscribe=YES">SUBSCRIBE</a></p> | |
<cfelse> | |
<h3>SUBSCRIBED!</h3> | |
</cfif> | |
</cfoutput> |
Here's another Gist with even more examples, including how to remove a member: https://gist.github.com/stevewithington/8528839
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
And remove?