• twitter image
  • facebook image
  • youtube image
  • linkedin image
Language: CMS Made Simple Czech CMS Made Simple France CMS Made Simple Spain CMS Made Simple Hungary CMS Made Simple Russia CMS Made Simple Netherlands

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed May 20, 2009 4:06 pm 
Offline
Administrator
Administrator
User avatar

Joined: Fri Jun 11, 2004 6:58 pm
Posts: 3334
Location: Fairless Hills, Pa USA
I'm in the process of setting up a paid registration site.  One of the things that I wanted to do was set it up so that users who register have the option of signing up for a mailing list.

So, I setup FrontEndUsers, SelfRegistration and NMS.  I just setup the standard FEU + SelfReg combo that's been discussed before.  The only real thing of note was that I created a checkbox property called mailing_list and assigned it to my group.

I then setup a list in NMS, which gave me a mailing list id of 1 (keep info for later).

The next step was to create a user defined tag.  I named it feu_to_nms or something -- doesn't really matter.  I then used this code:

Code:
if (!function_exists('MyGetModuleInstance'))
{
        function &MyGetModuleInstance($module)
        {
                global $gCms;

                if (isset($gCms->modules[$module]) &&
                        $gCms->modules[$module]['installed'] == true &&
                        $gCms->modules[$module]['active'] == true)
                {
                        return $gCms->modules[$module]['object'];
                }
                // Fix only variable references should be returned by reference
                $tmp = FALSE;
                return $tmp;
        }
}

global $gCms;

$nms = MyGetModuleInstance('NMS');
$feu = MyGetModuleInstance('FrontEndUsers');

if ($nms == FALSE || $feu == FALSE)
  return false;

//Get User
$feu_user = $feu->GetUserInfo($params['id']);

//Do they really exist?  Why are we here anyway?
if ($feu_user)
{
    //Did they click the checkbox?
    if ($feu->GetUserPropertyFull('mailing_list', $params['id']))
    {
        //Add user to NMS
        //array(1) -- represents the id of the mailing list to add them to.  Change the 1 to whatever you want.
        $nms->AddUser($feu_user[1]['username'], array(1), $feu->GetUserPropertyFull('first_name', $params['id']) . " " . $feu->GetUserPropertyFull('last_name', $params['id']));

        //Set the confirmed flag to true (they clicked the checkbox -- that's enough)
        $db =& $gCms->GetDb();
        $db->Execute('UPDATE ' . cms_db_prefix() . 'module_nms_users SET confirmed = 1 where email = ?', array($feu_user[1]['username']));
    }
}


This code makes a lot of assumptions, so you will have to change it to taste.  For instance, I'm concatinating my first_name and last_name properties to create a name in my NMS user.  I have FEU setup to use email address as the username -- if you don't, then you'll have to make some adjustments for that as well.  There is also a slight hack in there to set the user as confirmed, since NMS's API doesn't give me the option on user creation.  Also, look at the note for which mailing list id to use.

Then, I went to the Events list and found the "onUserRegistered" event.  I edited it and added my feu_to_nms UDT to the list.

Now, whenever someone registers and clicks that check box, the event will fire, this code will run and the user gets added to the mailing list.  Easy peasy.

_________________
http://about.me/tedkulp


Last edited by Ted on Wed May 20, 2009 4:14 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed May 20, 2009 5:01 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Wed Jan 02, 2008 11:39 pm
Posts: 2154
Location: Lewiston-Idaho
sweet.. ;D thanks for sharing :)

Cheers

_________________
Sorry. Too little support in projects, too little reason to not deprioritize. May-be if more attention is needed.
Follow me on Twitter | Follow me on FaceBook


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed Jun 10, 2009 5:17 pm 
Offline
Forum Members
Forum Members

Joined: Mon May 04, 2009 8:00 pm
Posts: 12
Hi Ted ,

Thanks a lot  for  sharing the  code with the community. You really helped me lot.
I was  banging my head for couple of days how  to disable the user  if they decide to change their info and uncheck the box.
I have  the  following code that does not work for some reason. I hope  you  have the  solution.

Thanks in advance
Chris

Code:

if (!function_exists('MyGetModuleInstance'))
{
        function &MyGetModuleInstance($module)
        {
                global $gCms;

                if (isset($gCms->modules[$module]) &&
                        $gCms->modules[$module]['installed'] == true &&
                        $gCms->modules[$module]['active'] == true)
                {
                        return $gCms->modules[$module]['object'];
                }
                // Fix only variable references should be returned by reference
                $tmp = FALSE;
                return $tmp;
        }
}

global $gCms;

$nms = MyGetModuleInstance('NMS');
$feu = MyGetModuleInstance('FrontEndUsers');

if ($nms == FALSE || $feu == FALSE)
  return false;

//Get User
$feu_user = $feu->GetUserInfo($params['id']);

//Do they really exist?  Why are we here anyway?
if ($feu_user)
{
    //Did they click the checkbox?
    if ($feu->GetUserPropertyFull('newsletter', $params['id']))
    {

        //Set the confirmed flag to true (they clicked the checkbox -- that's enough)
        $db =& $gCms->GetDb();
        $db->Execute('UPDATE ' . cms_db_prefix() . 'module_nms_users SET disabled = 1 where email = ?', array($feu_user[1]['username']));
    }
}



Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Tue Jun 16, 2009 5:03 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 24, 2006 5:59 pm
Posts: 907
Location: Mandan, ND
Nice work Ted. I'll be bookmarking this thread for future use :)

_________________
If all else fails, use a bigger hammer.

M@rtijn wrote:
This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed Mar 03, 2010 5:30 pm 
Offline
New Member

Joined: Wed Mar 03, 2010 3:53 am
Posts: 6
would love to also have it run a event  OnDeleteUser to remove them from the newsletter if they are deleted.


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed Mar 03, 2010 5:33 pm 
Offline
New Member

Joined: Wed Mar 03, 2010 3:53 am
Posts: 6
would also love to have it where, a checkbox for signing up the newsletter, when they update their information if they uncheck it, it would unsubscribe them from NMS.


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed Mar 03, 2010 5:34 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 24, 2006 5:59 pm
Posts: 907
Location: Mandan, ND
cwboaze:  http://dev.cmsmadesimple.org/feature_request/list/10

_________________
If all else fails, use a bigger hammer.

M@rtijn wrote:
This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed Mar 03, 2010 5:45 pm 
Offline
New Member

Joined: Wed Mar 03, 2010 3:53 am
Posts: 6
Thanks for that reference, it helped a lot.

I can do most of this myself. I just don't know the available commands,
used through NMS

like $nms->AddUser

what are the others. ? RemoveUser,EditUser, so on. and their required parameters if I know this, I can do the rest myself.

Appreciate your help!!


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Fri Mar 05, 2010 10:59 pm 
Offline
New Member

Joined: Wed Mar 03, 2010 3:53 am
Posts: 6
can anyone supply me with these functions.?? if not, I'll read through the module code, and find it myself.


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Wed Jan 05, 2011 11:50 am 
Offline
Forum Members
Forum Members

Joined: Thu Jan 17, 2008 10:26 am
Posts: 59
Great thanks!


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Mon Feb 21, 2011 2:11 am 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
Thanks for the Tip.. Been looking for this for a while...

Question.. Is there a way to do 1 of either of these:

1) Automatically have the box checked by default?
or
2) Simply automatically register them for the newsletter when they register since the people joining the site are all associates and the newsletter is simply included as a form of constant communication for the group?


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Mon Feb 21, 2011 2:31 pm 
Offline
Power Poster
Power Poster
User avatar

Joined: Tue Oct 24, 2006 5:59 pm
Posts: 907
Location: Mandan, ND
You could use jQuery to check the checkbox.

Code:
$('.checkbox').attr('checked','checked')

_________________
If all else fails, use a bigger hammer.

M@rtijn wrote:
This is a community. This means that we work together and have the same goal (a beautiful CMS), not that we try to put people down and make their (voluntary) job as difficult as can be.


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Mon Feb 21, 2011 3:07 pm 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
tyman00 wrote:
You could use jQuery to check the checkbox.

Code:
$('.checkbox').attr('checked','checked')


Thanks for the response.. so in the example code that ted posted.. would I insert this portion right after the:

//Did they click the checkbox?
if ($feu->GetUserPropertyFull('mailing_list', $params['id']))

or would it go into the code in another place.

Thanks again for the help...


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Thu Mar 10, 2011 2:26 am 
Offline
Forum Members
Forum Members

Joined: Mon Feb 21, 2011 2:08 am
Posts: 50
Any help here.. I am lost right now trying to get this to auto check?


Top
 Profile  
 
 Post subject: Re: FrontEndUsers to NMS (via SelfRegistration)
PostPosted: Tue Mar 15, 2011 9:47 am 
Offline
Forum Members
Forum Members

Joined: Thu Jan 17, 2008 10:26 am
Posts: 59
I put this in my template:

Code:
<body onload="
document.getElementById('m11515moduleform_2').m11515input_mailing_list.checked = true;
">


m11515moduleform_2 is the form id

m11515input_mailing_list is the checkbox name

Maybe not the best option but it works :).


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Arvixe - A CMSMS Partner