Since the User Manager in 2.5 has the option to do a Mass Mail simply by selecting which groups to send to, I think this is a logical solution, if only I can figure out how to assign this group through some sort of php script directly associated with the profile plugin. Any ideas, of course, are totally welcome.
Thanks to using code from this: http://docs.joomla.org/Creating_a_profile_plugin I've got the radio buttons made, now I just need to make them do something!
Any ideas peoples!?
=======
UPDATE
=======
Ok, this is going to be embarrassing, but seeing as I don't know PHP, I think I've gotten pretty close to cobbling together some code for this, but it still doesn't work. I'm probably making some terrible simple syntax error and just don't know it. Anyway, I have come up with this code to add to the profile.php file that "comes with" Joomla.
Here's what I did.
I added these imports to the top of profile.php
Code: Select all
jimport( 'joomla.user.helper' );
jimport( 'joomla.user.user');
jimport( 'joomla.utilities.arrayhelper' );
Code: Select all
function onUserAfterSave($data, $isNew, $result, $error)
{
$userId = JArrayHelper::getValue($data, 'id', 0, 'int');
//
//BEGIN CUSTOM CODE
//
//put this inside the onUserAfterSave function in profile.php
// This code will check if the user clicked the radio button for email
// updates by checking the 'subscribe' boolean in the data
// then assign the user to that group (group 9) if true
$groupID = 9; //9 is the value for the subscriber group in the ACL
$subscribeFlag = JArrayHelper::getValue($data, 'subscribe', 0, 'boolean');
//DEBUG code that forces if statement to come up true
//$subscribeFlag = 1;
echo $subscribeFlag;
if (!($subscribeFlag == 0))
{
try
{
JUserHelper::addUserToGroup($userId, $groupID);
}
catch (JException $e)
{
$this->_subject->setError($e->getMessage());
return false;
}
}
//END CUSTOM CODE
//
If I un-comment the line:
Code: Select all
//$subscribeFlag = 1;
So my problem appears to be in retrieving the value from the radio button.
The line above:
Code: Select all
$subscribeFlag = JArrayHelper::getValue($data, 'subscribe', 0, 'boolean');
Hopefully this is a simple PHP fundamental thing that I will figure out soon...
Thanks in advance
Cheers!
ultramanjones