Skip to content

Instantly share code, notes, and snippets.

@dwanjuki
Created January 19, 2026 12:42
Show Gist options
  • Select an option

  • Save dwanjuki/dddcea07120435ab77c52cfcf3ad9298 to your computer and use it in GitHub Desktop.

Select an option

Save dwanjuki/dddcea07120435ab77c52cfcf3ad9298 to your computer and use it in GitHub Desktop.
Save User Fields from checkout when a Pay By Check pending order is created.
<?php // copy from below.
/**
* Save User Field values from checkout when a Pay By Check pending order is created.
*
* 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_pmpropbc_added_order_save_fields( $morder ) {
// Check orders only.
if ( 'check' !== $morder->gateway ) {
return;
}
// Bail if order is added via admin dashboard.
if ( is_admin() ) {
return;
}
// Loop through all the field groups.
$field_groups = PMPro_Field_Group::get_all();
$user_creation_field_groups = pmpro_get_user_creation_field_groups();
foreach ( $field_groups as $group_name => $group ) {
if ( in_array( $group_name, $user_creation_field_groups ) ) {
continue;
}
// Save the fields.
$group->save_fields(
array(
'user_id' => $user_id,
'scope' => 'checkout',
)
);
}
}
add_action( 'pmpro_added_order', 'my_pmpropbc_added_order_save_fields', 20, 1 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment