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 kimcoleman/e6f6ab5acedd47aacb9d0dad808b946b to your computer and use it in GitHub Desktop.
Save kimcoleman/e6f6ab5acedd47aacb9d0dad808b946b to your computer and use it in GitHub Desktop.
Display a member's gravatar and a link to update at Gravatar on the Membership Account page "Profile" section.
<?php
/*
* Show a link to Gravatar and an avatar preview on the Profile section of the Membership Account 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 show_gravatar_pmpro_account_bullets_top() {
global $current_user;
echo '<li class="alignright" style="display: inline-block; list-style: none; margin: -5rem 0 0 0;">' . get_avatar( $current_user->ID, 160 ) . '</li>';
}
add_action( 'pmpro_account_bullets_top', 'show_gravatar_pmpro_account_bullets_top' );
function show_gravatar_pmpro_account_bullets_bottom() {
echo '<li><strong>' . __( 'Avatar', 'my-textdomain' ) . ':</strong> <a href="http://gravatar.com/" target="_blank">' . __('Update at Gravatar.com', 'my-textdomain') . '</a></li>';
}
add_action( 'pmpro_account_bullets_bottom', 'show_gravatar_pmpro_account_bullets_bottom');
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Recommended Plugins for WordPress User Avatar Support in Your Membership Site" at Paid Memberships Pro here: https://www.paidmembershipspro.com/recommended-plugins-for-user-avatar-management-on-your-wordpress-membership-site/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment