Support » Plugin: Ultimate Member – User Profile, User Registration, Login & Membership Plugin » Send unique email dependent on registration form

  • Resolved bt_dev

    (@biotrace)


    We have four different registration forms and would like to send unique email content depending on which form is used. Ideally we would like to send the “Account Approved Email” with content specific to which form was originally submitted. Is this currently possible or is there a code snippet to achieve this?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    Hello @biotrace

    Ultimate member currently does not have this feature but you can achieve this will some custom codes. Please have a look at this similar topic for help.

    Thread Starter bt_dev

    (@biotrace)

    Thank you for your reply Aswin. The code in the topic you suggested sounds like it could potentially achieve the results we are after. Thank you for the recommendation.

    gelieys

    (@gelieys)

    Hi @biotrace

    Did the recommended solution help you achieve your need? If yes, please help us mark this topic as Resolved.

    Regards,

    Thread Starter bt_dev

    (@biotrace)

    Hi @gelieys

    The solution is mostly working but am wondering if it is possible to send a default email template if a user role is not specified in the code snippet?

    For example in the code below we are sending custom email templates to the ‘um_retailer’ and the ‘um_practitioner’ roles. Are we able to send a default template to all other roles not specified in the snippet? Or do we have to add all user roles to the snippet and specify the template they should use?

    /**
     * Send custom email templates (depending on UM user role) on UM User approve action.
     * @param  int $user_id  User ID.
     * @return boolean
     */
    function custom_um_after_user_is_approved( $user_id = null ) {
    
    	if ( empty( $user_id ) ) {
    		$user_id = get_current_user_id();
    	}
    
    	$status = get_user_meta( $user_id, 'account_status', true );
    	if ( 'approved' !== $status ) {
    		return;
    	}
    
    	$rolename = UM()->roles()->get_priority_user_role( $user_id );
    	$userdata = get_userdata( $user_id );
    
    	switch ( $rolename ) {
    		case 'um_retailer':
    			UM()->mail()->send( $userdata->user_email, 'retailer_approved_email' );
    			break;
    		case 'um_practitioner':
    			UM()->mail()->send( $userdata->user_email, 'practitioner_approved_email' );
    			break;
    		default:
    			break;
    	}
    }
    
    add_action( 'um_after_user_is_approved', 'custom_um_after_user_is_approved' );
    gelieys

    (@gelieys)

    Hi @biotrace ,

    You can send the global template to other roles using the default condition.

    See the example below:

    switch ( $rolename ) {
    		case 'um_retailer':
    			UM()->mail()->send( $userdata->user_email, 'retailer_approved_email' );
    			break;
    		case 'um_practitioner':
    			UM()->mail()->send( $userdata->user_email, 'practitioner_approved_email' );
    			break;
    		default:
    			UM()->mail()->send( $userdata->user_email, 'global_approved_email' );
    			break;
    	}
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.