Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ipokkel/afc3b556443f12d6fa047fc409b3c6da to your computer and use it in GitHub Desktop.
Save ipokkel/afc3b556443f12d6fa047fc409b3c6da to your computer and use it in GitHub Desktop.
<?php
/**
* Change the default submit button text on the checkout 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 my_pmpro_change_default_button_text_per_level() {
$checkout_level = pmpro_getLevelAtCheckout();
switch ( $checkout_level->id ) {
case '1':
$submit_button_text = 'Your Custom Text for Level 1';
break;
case '5':
$submit_button_text = 'Your Custom Text for Level 5';
break;
default:
$submit_button_text = 'Create Account';
break;
}
?>
<span id="pmpro_submit_span">
<input type="hidden" name="submit-checkout" value="1" />
<input type="submit" id="pmpro_btn-submit" class="<?php echo esc_attr( pmpro_get_element_class( 'pmpro_btn pmpro_btn-submit-checkout', 'pmpro_btn-submit-checkout' ) ); ?>" value="<?php esc_html_e( $submit_button_text) ?>" />
</span>
<?php
//show default checkout button
return false;
}
add_filter( 'pmpro_checkout_default_submit_button', 'my_pmpro_change_default_button_text_per_level' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment