load( array( 'id' => 'donor-register', 'label' => __( 'User Registration Information', 'give' ), 'description' => __( 'Sent to the donor when they register for an account on the site.', 'give' ), 'notification_status' => 'enabled', 'form_metabox_setting' => false, 'recipient_group_name' => __( 'Donor', 'give' ), 'email_tag_context' => array( 'donor', 'general' ), 'default_email_subject' => sprintf( /* translators: %s: site name */ esc_attr__( '[%s] Your username and password', 'give' ), get_bloginfo( 'name' ) ), 'default_email_message' => $this->get_default_email_message(), 'default_email_header' => __( 'New User Registration', 'give' ), ) ); // Setup action hook. add_action( "give_{$this->config['id']}_email_notification", array( $this, 'setup_email_notification' ), 10, 2 ); add_filter( 'give_email_preview_header', array( $this, 'email_preview_header' ), 10, 2 ); } /** * Get default email message. * * @since 2.0 * @access public * * @return string */ function get_default_email_message() { $message = esc_attr__( 'Username: {username}', 'give' ) . "\r\n\r\n"; $message .= __( 'To reset your password, simply click the link below which will take you to a web page where you can create a new password.', 'give' ) . "\r\n"; $message .= '{reset_password_link}' . "\r\n\r\n"; $message .= __( 'After resetting password, Please login to your account with link below.', 'give' ) . "\r\n"; $message .= ' ' . esc_attr__( 'Click Here to Login »', 'give' ) . '' . "\r\n"; /** * Filter the default email message * * @since 2.0 */ return apply_filters( "give_{$this->config['id']}_get_default_email_message", $message, $this ); } /** * Setup and send new donor register notifications. * * @since 2.0 * @access public * * @param int $user_id User ID. * @param array $user_data User Information. * * @return string */ public function setup_email_notification( $user_id, $user_data ) { $this->setup_email_data(); $this->recipient_email = $user_data['email']; $this->send_email_notification( array( 'user_id' => $user_id, ) ); } /** * email preview header. * * @since 2.0 * @access public * * @param string $email_preview_header * @param Give_Donor_Register_Email $email * * @return bool */ public function email_preview_header( $email_preview_header, $email ) { // Bailout. if ( $this->config['id'] !== $email->config['id'] ) { return $email_preview_header; } // Payment receipt switcher $user_id = give_check_variable( give_clean( $_GET ), 'isset', 0, 'user_id' ); // Get payments. $donors = new Give_API(); $donors = give_check_variable( $donors->get_donors(), 'empty', array(), 'donors' ); $options = array(); // Default option. $options[0] = esc_html__( 'No donor(s) found.', 'give' ); // Provide nice human readable options. if ( $donors ) { $options[0] = esc_html__( '- Select a donor -', 'give' ); foreach ( $donors as $donor ) { // Exclude customers for which wp user not exist. if ( ! $donor['info']['user_id'] ) { continue; } $options[ $donor['info']['user_id'] ] = esc_html( '#' . $donor['info']['donor_id'] . ' - ' . $donor['info']['email'] ); } } $request_url_data = wp_parse_url( $_SERVER['REQUEST_URI'] ); $query = $request_url_data['query']; // Remove user id query param if set from request url. $query = remove_query_arg( array( 'user_id' ), $query ); $request_url = home_url( '/?' . str_replace( '', '', $query ) ); ?>