Created
October 25, 2023 06:44
-
-
Save ipokkel/f794a6588314cd1ea201a26f922d2d2b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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