Skip to content

Instantly share code, notes, and snippets.

@sc0ttkclark
Last active November 11, 2021 22:57
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 sc0ttkclark/afac8d85d1deb28b1845c5abcdae36c4 to your computer and use it in GitHub Desktop.
Save sc0ttkclark/afac8d85d1deb28b1845c5abcdae36c4 to your computer and use it in GitHub Desktop.
Show the PMPro Pods fields on the My Membership Account page under the Account Details (Profile) section. This functionality will be unnecessary in a future PMPro Pods Add On vesion.
<?php
/**
* Show the PMPro Pods fields on the My Membership Account page under the Account Details (Profile) section.
*
* This functionality will be unnecessary in a future PMPro Pods Add On vesion.
*
* 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/
*/
/**
* Output the PMPro Pods fields onto the page.
*/
function my_pmpro_pods_account_details_fields() {
// @todo Set your fields here.
$fields_to_show = [
'my_field_name' => 'Text label to show',
't-shirt_size' => 'T-shirt Size',
];
$pod = pods( 'pmpro_membership_user', get_current_user_id() );
foreach ( $fields_to_show as $field_name => $field_label ) {
$value = $pod->display( $field_name );
// Skip empty values.
if ( empty( $value ) ) {
continue;
}
printf(
'<li><strong>%1$s:</strong> %2$s</li>',
esc_html( $field_label ),
$value
);
}
}
add_action( 'pmpro_account_bullets_bottom', 'my_pmpro_pods_account_details_fields' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment