WordPress.org

Ready to get started?Download WordPress

Forums

Edit Flow
[resolved] Notify a non-admin of posts awaiting review (3 posts)

  1. Grievy
    Member
    Posted 3 years ago #

    Is there a way to change it so when a post is submitted for review rather than emailing the administrator it instead emails a user with the Editor role??

  2. muaysteve
    Member
    Posted 3 years ago #

    I would be interested in this as well.

  3. Grievy
    Member
    Posted 3 years ago #

    Insert the following into php/templates/functions.php

    add_action( 'ef_init', 'ef_x_init_email_all_admins' );
    
    function ef_x_init_email_all_admins() {
    
    	add_filter( 'ef_notification_recipients', 'ef_x_email_all_admins', 10, 3 );
    
    }
    
    function ef_x_email_all_admins( $recipients, $post, $return_as_string ) {
    
    	$admins = ef_x_get_users_in_role( 'editor' );
    
    	if( ! empty( $admins ) ) {
    
    		foreach( $admins as $admin ) {
    
    			$recipients[] = $admin->user_email;
    
    		}
    
    	}
    
    	return $recipients;
    
    }
    
    function ef_x_get_users_in_role( $role ) {
    
    	$users = array();
    
    	if( function_exists( 'get_users' ) ) {
    
    		$users = get_users( array( 'role' => $role ) ); 
    
    	} elseif( class_exists( 'WP_User_Search' ) ) {
    
    		global $wpdb;
    
    		$wp_user_search = new WP_User_Search( '', '', $role );
    
    		foreach( $wp_user_search->get_results() as $user_id ) {
    
    			$users[] = new WP_User( $user_id );
    
    		}
    
    	}
    
    	return $users;
    
    }

    Just change editor to whatever userrole you want notified.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags