Recent Topics

[2.x] Modify Contact form to email more than one person

Started by on Jan 18, 2010 – Contents updated: Jan 18, 2010

Jan 18, 2010 18:06    

My b2evolution Version: 2.x

I have 2 admins on my blog and want to modify the Contact form to email us both. How can I most easily accomplish this?

Jan 18, 2010 22:28

You can create another user with different email, then in emai settings (cpanel or whatever) choose to send copies to admin emails

Moved to feature requests

Jan 19, 2010 16:24

I'm looking to do this in b2 itself via modifying the contact form itself or whatever it is that sends an email to the registered admin's email address in b2's blog settings. Or of course asking for a hack that allows you to tell b2 you have more than one admin so when it sends an email it can send to however many you want (in this case 2).

Jan 19, 2010 20:29

You can make a simple plugin to handle this. Check the "skeleton plugin" for ideas

The core function will be

/**
 * Event handler: Called when a message form has been submitted.
 *
 * Add messages of category "error" to prevent the message from being sent.
 *
 * You can also alter the "message" or "message_footer" that gets sent here.
 *
 * @param array Associative array of parameters
 *   - 'recipient_ID': ID of the user (if any)
 *   - 'item_ID': ID of the item where the user clicked the msgform icon (if any)
 *   - 'comment_ID': ID of the comment where the user clicked the msgform icon (if any)
 *   - 'sender_name': The name of the sender (by reference) (since 1.10.0)
 *   - 'sender_email': The email address of the sender (by reference) (since 1.10.0)
 *   - 'subject': The subject of the message to be sent (by reference) (since 1.10.0)
 *   - 'message': The message to be sent (by reference)
 *   - 'message_footer': The footer of the message (by reference)
 *   - 'Blog': The blog, depending on the context (may be null) (by reference) (since 1.10.0)
 */
function MessageFormSent( & $params )
{
	$UserCache = & get_Cache('UserCache');
	
	if( $params['recipient_ID'] == 1 ) // If recipient User #1
	{
		$User = & $UserCache->get_by_ID(3); // Get another User by ID
		
		// Send a copy to user #3
		send_mail( $User->get('email'),
				   trim($User->get('preferredname')),
				   $params['subject'],
				   $params['message'],
				   $params['sender_email'],
				   $params['sender_name'] );
	}
	
	
	// Same as above, but for another user
	if( $params['recipient_ID'] == 3 ) // If recipient User #3
	{
		$User = & $UserCache->get_by_ID(1); // Get another User by ID
		
		// Send a copy to user #3
		send_mail( $User->get('email'),
				   trim($User->get('preferredname')),
				   $params['subject'],
				   $params['message'],
				   $params['sender_email'],
				   $params['sender_name'] );
	}
}

May 11, 2010 23:27

I really need to do this to... i have chosen to use B2E as blog for a few clients only to discover all the emails are only able to be sent to me.

I'm in a situation where I want the client who the blog belongs to to get the emails too, but they are not computer savvy and can't be trusted to have admin access, so I want the emails to go to them AND me.

did anyone create this hack or found a way to do this? seems like you should be able to specify two emails for admin and that'd be that, but I tried entering two email addys on the admin account and it was not accepted :(

thanks for any other suggestions or help!

May 11, 2010 23:59

As I already wrote above, you can configure your email software to send a copy to another address


Form is loading...

Run your own website! – This forum is powered by b2evolution CMS, a complete engine for your website.