Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimwhite/27bbd99c3a6a7597a1fdaf5fa2407521 to your computer and use it in GitHub Desktop.
Save kimwhite/27bbd99c3a6a7597a1fdaf5fa2407521 to your computer and use it in GitHub Desktop.
PMPro - Change Text Example on Checkout Page by LEVEL
<?php // Do Not Copy This Line
/**
* This recipe will help you change text on the checkout paid by level
* 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/
*/
// paste content from below this line
function pmproc_change_my_text( $translated_text, $text, $domain ) {
switch ( $translated_text ) {
case 'Account Information':
$translated_text = __( 'Gift Information ', 'pmpro' );
break;
case 'Membership Checkout':
$translated_text = __( 'Application', 'pmpro' );
break;
case 'Membership Level':
$translated_text = __( 'Application', 'pmpro' );
break;
case 'Do you have a discount code?':
$translated_text = __( 'Do you have a membership code?', 'pmpro' );
break;
case 'Click here to enter your discount code':
$translated_text = __( 'Click here to enter your membership code', 'pmpro' );
break;
case 'You have selected the <strong>%s</strong> membership level.':
$translated_text = __( '<strong>%s</strong> has been selected.', 'pmpro' );
break;
case 'The price for membership is <strong>%s</strong> now':
$translated_text = __( ' you can leave this blank ', 'pmpro' );
break;
}
return $translated_text;
}
function do_gettext_for_pmpro_checkout() {
global $pmpro_level;
if ( '1' === $pmpro_level->id ) {
add_filter( 'gettext', 'pmproc_change_my_text', 20, 3 );
}
}
add_action( 'pmpro_checkout_preheader', 'do_gettext_for_pmpro_checkout' );
/**
* This function will change the Page Title on the Checkout page for 1 level
*/
function my_checkout_page_title( $page_title, $page_id ) {
/* Settings - set your level ID and page title here */
$level_id = '1';
$level_page_title = 'Application';
/* END */
global $pmpro_pages;
if ( $page_id == $pmpro_pages['checkout'] && isset( $_REQUEST['level'] ) && $_REQUEST['level'] == $level_id ) {
$page_title = $level_page_title;
}
return $page_title;
}
add_filter( 'the_title', 'my_checkout_page_title', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment