Skip to content

Instantly share code, notes, and snippets.

@ipokkel
Created October 25, 2023 06:44
Show Gist options
  • Save ipokkel/f794a6588314cd1ea201a26f922d2d2b to your computer and use it in GitHub Desktop.
Save ipokkel/f794a6588314cd1ea201a26f922d2d2b to your computer and use it in GitHub Desktop.
<?php
/**
* Display user data as a bullet on the PMPro Invoice page.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_custom_invoice_bullet_top( $invoice ) {
$user = get_userdata( $invoice->user_id );
// First and Last name
if ( ! empty( $user->first_name ) && ! empty( $user->last_name ) ) {
echo '<li><strong>Name: </strong>' . esc_html( $user->first_name ) . ' ' . esc_html( $user->last_name ) . '</li>';
}
// Nickname
if ( ! empty( $user->nickname ) ) {
echo '<li><strong>Nickname: </strong>' . esc_html( $user->nickname ) . '</li>';
}
}
add_action( 'pmpro_invoice_bullets_top', 'my_pmpro_custom_invoice_bullet_top' );
function my_pmpro_custom_invoice_bullet_bottom( $invoice ) {
$user = get_userdata( $invoice->user_id );
// Company Name
if ( ! empty( $user->company_name ) ) {
echo '<li><strong>Company: </strong>' . esc_html( $user->company_name ) . '</li>';
}
}
add_action( 'pmpro_invoice_bullets_bottom', 'my_pmpro_custom_invoice_bullet_bottom' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment