Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: nosx on August 13, 2011, 04:23:53 AM

Title: sendpm to group(s)
Post by: nosx on August 13, 2011, 04:23:53 AM
Hello,

How do I send a pm to a GROUP of members using the using the sendpm() (http://support.simplemachines.org/function_db/index.php?action=view_function;id=315) function ?

Thanks,
Nosx
Title: Re: sendpm to group(s)
Post by: Ricky. on August 13, 2011, 05:55:20 AM
I just wonder why would you like to do that as SMF already have built in feature to send PM to particular group from Admin -> News and Newsletter ---> Newsletter --> Send this message as PM .

If still something you want to do through coding or custom, below is function details :
http://support.simplemachines.org/function_db/index.php?action=view_function;id=315
Title: Re: sendpm to group(s)
Post by: nosx on August 13, 2011, 06:49:50 AM
A.) I already know HOW to send a pm and if you noticed in my post I supplied the exact same link you did so I already knew about it.

B.) I am sending the messages at defined intervals using a CRON job and before you say to set up a task to do this then that will not work either as SMF task scheduler is not flexible enough for my needs.

C.) As I said above I already know how to send a pm to one or more members by adding their member id to the $recipients array defined in sendpim() function. All I need to know is how to set it to go to a group instead of individual members.

In other words..


$recipients = array(
'to' => array(what_do_I_need_to_put_here_to_send_to_a_group),
'bcc' => array()
  );


Thx,
Nosx
Title: Re: sendpm to group(s)
Post by: Ricky. on August 13, 2011, 07:05:24 AM
Ok then.. I overlooked,
Now since you know all things apart that you can't send PM to any particular member group using this function directly rather you can query a membergroup and then save those members in $recipient array and then send PM them to all !
Hope that gives you idea.
Title: Re: sendpm to group(s)
Post by: nosx on August 13, 2011, 07:15:14 AM
Makes sense. Thanks

Nosx
Title: Re: sendpm to group(s)
Post by: Ricky. on August 13, 2011, 07:57:56 AM
Also to make it easier their is simple function which can allow you to get list of users from a membergroup :
http://support.simplemachines.org/function_db/index.php?action=view_function;id=49
Title: Re: sendpm to group(s)
Post by: Jokerâ„¢ on August 13, 2011, 09:43:07 AM
You can try this -- http://custom.simplemachines.org/mods/index.php?mod=2178