Last active
November 11, 2021 22:57
-
-
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.
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 | |
/** | |
* 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