Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ipokkel/585d68c80bd5bdbf1f555a92c286ecc1 to your computer and use it in GitHub Desktop.
Save ipokkel/585d68c80bd5bdbf1f555a92c286ecc1 to your computer and use it in GitHub Desktop.
Display a usermeta field captured with Register Helper as a bullet on the Account, Billing and Invoice page.
<?php
/**
* This recipe displays a usermeta field as a bullet on
* the Account, Billing and Invoice page through using
* available action hooks on those pages.
*
* Action hooks:
* Account Page: pmpro_account_bullets_top, pmpro_account_bullets_botttom
* Billing Page: pmpro_billing_bullets_top, pmpro_billing_bullets_botttom
* Invoice Page: pmpro_invoice_bullets_top, pmpro_invoice_bullets_botttom
*
* This recipe assumes that the usermeta field "company" exists in the database.
* Capturing usermeta data may be achieved with the Register Helper Add On.
* Example:
* @link https://gist.github.com/ipokkel/d35c6a7db826a2ad96986dda0479f56b
*
* 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_usermeta_bullet() {
if ( is_user_logged_in() ) {
global $current_user;
//get company name
$company_name = get_user_meta( $current_user->ID, 'company', true );
if ( ! empty( $company_name ) ) {
echo '<li><strong>Company: </strong>' . $company_name . '</li>';
}
}
}
add_action( 'pmpro_account_bullets_top', 'my_usermeta_bullet' );
add_action( 'pmpro_billing_bullets_top', 'my_usermeta_bullet' );
add_action( 'pmpro_invoice_bullets_top', 'my_usermeta_bullet' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment