• Resolved ddrapeau

    (@ddrapeau)


    I have two sites that use Ultimate Member. Both site had severe server errors and crashed upon auto-update to UM 2.6.1

    Both sites make use of custom email templates I added via Code Snippet. When I disable the snippet that uses add_filter( ‘um_email_notifications’, the site works with UM 2.6.1 … If I enable the snippet it dies with UM 6.2.1.

    The snippet will work with UM 6.2.0 so that’s where I’m holding for now.

    I suspect it may have to do with the adding of the ‘um_email_get_template_file_path’ hook in 6.2.1

    Here is a PHP error message that gets thrown:

    PHP Fatal error: Uncaught Error: Call to private method um\core\Mail::locate_template()

    And here is the PHP code I use for the custom template:

    /**
     * Add custom email templates
     * @param  array $emails Emails list.
     * @return array
     */
    function um_email_notification_member_needs_renewal( $emails ) {
    
    	// New email template for membership needing renewal.
    	$custom_emails = array(
    		'member_needs_renewal'	 => array(
    			'key'            => 'member_needs_renewal',
    			'title'          => __( 'Member needs Renewal - Annual membership expired', 'ultimate-member' ),
    			'description'    => __( 'Whether to send a user an email when their annual membership expired', 'ultimate-member' ),
    			'recipient'      => 'user',
    			'default_active' => true,
    			'subject'        => 'Your OGP Membership has expired',
    			'body'           => 'Hello {display_name}, <br /> ' .
                                                 'You are getting this message because your OGP membership needs renewal.<br />',
    		),
    	);
    
    	foreach ( $custom_emails as $slug => $custom_email ){
    		// Default settings.
    		if ( ! array_key_exists( $slug.'_on', UM()->options()->options ) ) {
    			UM()->options()->options[ $slug.'_on' ]  = empty( $custom_email['default_active'] ) ? 0 : 1;
    			UM()->options()->options[ $slug.'_sub' ] = $custom_email['subject'];
    		}
    
    		// Template file.
    		$located = UM()->mail()->locate_template( $slug );
    		if ( ! file_exists( $located ) ) {
    			file_put_contents( $located, $custom_email['body'] );
    		}
    
    		$emails[ $slug ] = $custom_email;
    	}
    
    	return $emails;
    }
    add_filter( 'um_email_notifications', 'um_email_notification_member_needs_renewal' );
    • This topic was modified 1 year, 7 months ago by ddrapeau.
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Release 2.6.1 breaks add_filter( ‘um_email_notifications’,’ is closed to new replies.