• Resolved Ayana Memon

    (@ayana24797)


    Hello,
    i am creating functionality of mail.
    When new user / student will register on the site then teacher and admin get mail of new user registration.

    i tried

    function custom_um_email_notifications_after_user_is_approved( $emails ) {
    
    	 //New email templates 
    	$custom_emails = array(
    		'teacher_email'	 => array(
    			'key'			=> 'teacher_email',
    			'title'			=> __( 'Account Welcome Email, Group 1', 'ultimate-member' ),
    			'subject'		=> 'Welcome to {site_name}!',
    			'body'			=> '',
    			'description'		=> __( 'Whether to send the user (Group 1) an email when his account is automatically approved.', 'ultimate-member' ),
    			'recipient'		=> 'user',
    			'default_active'	=> true
    		),
    		'admin_email'	 => array(
    			'key'			=> 'admin_email',
    			'title'			=> __( 'Account Welcome Email, Group 2', 'ultimate-member' ),
    			'subject'		=> 'Welcome to {site_name}!',
    			'body'			=> '',
    			'description'		=> __( 'Whether to send the user (Group 2) an email when his account is automatically approved.', 'ultimate-member' ),
    			'recipient'		=> 'user',
    			'default_active' 	=> true
    		),
    	);
    
    	// Default settings 
    	UM()->options()->options = array_merge( array(
    		'teacher_email_on'	 => 1,
    		'teacher_email_sub'	 => 'Welcome to {site_name}!',
    		'admin_email_on'	 => 1,
    		'admin_email_sub'	 => 'Welcome to {site_name}!',
    		), UM()->options()->options );
    
    	return array_merge( $custom_emails, $emails );
    }
    
    add_filter( 'um_email_notifications', 'custom_um_email_notifications_after_user_is_approved' );
    
    function registration_notification( $user_id, $args ) {
    	um_fetch_user( $user_id );
    	$emails = um_multi_admin_email();
    	
    	if(UM()->user()->get_role() == 'students'):
    		UM()->mail()->send( $email, 'teacher_email' );
    		UM()->mail()->send( $email, 'admin_email');
    	endif;
    	if ( ! empty( $emails ) ) {
    		foreach ( $emails as $email ) {
    			if ( um_user( 'account_status' ) != 'pending' ) {
    				UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
    			} else {
    				UM()->mail()->send( $email, 'notification_review', array( 'admin' => true ) );
    			}
    		}
    	}
    }
    add_action( 'um_registration_complete', 'registration_notification', 10, 2 );

    but this code is not working..
    please team help me to solve this issue..

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter Ayana Memon

    (@ayana24797)

    please help me @ultimatemembersupport to find solution

    Thread Starter Ayana Memon

    (@ayana24797)

    No Any Reply from Support team ??
    By the Way, I solved it by my self, using this code..

    write this code in functions.php file.

    function registration_notification_teacher( $user_id, $args ) {
    	$get_users = get_users();
    	foreach($get_users as $users):
    	    if($users->roles[0] == 'um_teacher'):
    	        $student_data = get_userdata($user_id);
    	        $teacher_id_student = get_user_meta($student_data->ID,'students_teacher',true);
    	        $teacher_id = $users->ID;
    	        if($teacher_id == $teacher_id_student):
    	        	UM()->mail()->send( $email, 'notification_new_user', array( 'admin' => true ) );
    	            UM()->mail()->send($users->user_email , 'notification_new_user', array( 'admin' => true ));
    	        endif;
    	    endif;
    	    // $user->roles[0]; //um_teacher
    	endforeach;
    }
    add_action( 'um_registration_complete', 'registration_notification_teacher', 10, 2 );
    gelieys

    (@gelieys)

    You can also check this article on How to Enable Email Notification on Activation or Admin Review Upon User’s Registration

    • This reply was modified 3 years ago by gelieys.
    Thread Starter Ayana Memon

    (@ayana24797)

    Hello, @gelieys
    I checked this article,
    This is only for admin role,
    I wanted that when students will register then teacher get notification.
    But ok, i done this functionality.
    Thank You ??

    Plugin Support Ultimate Member Support

    (@ultimatemembersupport)

    Thanks for letting us know how you resolve the issue.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Mail to Teacher Role When New user Register.’ is closed to new replies.