Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimwhite/9c940b0a9c664bfd8baa2a3c3ccf9eaa to your computer and use it in GitHub Desktop.
Save kimwhite/9c940b0a9c664bfd8baa2a3c3ccf9eaa to your computer and use it in GitHub Desktop.
Change or translate text for PMPro Member Directory and Profile with gettext. #pmpro-member-directory
<?php
/**
* This recipe is an example of how to change localized text strings
* for PMPro Member Directory Add On.
*
* 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/
*/
/**
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function change_text_for_member_directory_and_profile_pages( $translated_text, $text, $domain ) {
if ( 'pmpromd' === $domain || 'pmpro-member-directory' === $domain ) {
switch ( $text ) {
case 'Hide from %s?':
$translated_text = __( ' Your translation here', 'pmpro-member-directory' );
break;
case 'Viewing All Profiles':
$translated_text = __( 'Your translation here', 'pmpro-member-directory' );
break;
case 'Showing 1 Result':
$translated_text = __( 'Your translation here', 'pmpro-member-directory' );
break;
case 'Showing %s-%s of %s Results':
$translated_text = __( 'Your translation here', 'pmpro-member-directory' );
break;
case 'Email Address':
$translated_text = __( 'Your translation here', 'pmpro-member-directory' );
break;
case 'Search Members':
$translated_text = __( 'Your translation here', 'pmpro-member-directory' );
break;
case 'No matching profiles found':
$translated_text = __( 'Your message here', 'pmpro-member-directory' );
break;
}
}
return $translated_text;
}
add_filter( 'gettext', 'change_text_for_member_directory_and_profile_pages', 20, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment