Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MaryOJob/e08da6016b7d3a243f830d53369477b4 to your computer and use it in GitHub Desktop.
Save MaryOJob/e08da6016b7d3a243f830d53369477b4 to your computer and use it in GitHub Desktop.
Send custom field(s) from WordPress to Aweber through the PMPro Aweber addon
<?php // do not copy this line
/*
* This example sends two custom fields from WordPress to AWeber through the PMPro AWeber addon.
* Go to Aweber to create your custom field(s)
* Make sure the custom field in aweber matches the input name for your custom fields added via the Register Helper extension
* Add this code to your active theme's functions.php or a custom plugin: https://www.paidmembershipspro.com/how-to-add-code-to-wordpress/
*/
function my_pmpro_aweber_custom_fields( $fields, $user ) {
// Set custom fields to add to Aweber
$custom_fields = array( 'phone', 'qualification' );
foreach ( $custom_fields as $field ) {
$field_value = ! empty( $_REQUEST[ $field ] ) ? $_REQUEST[ $field ] : get_user_meta( $user->ID, $field, true );
if ( ! empty( $field_value ) ) {
$fields[ $field ] = $field_value;
}
}
return $fields;
}
add_filter( 'pmpro_aweber_custom_fields', 'my_pmpro_aweber_custom_fields', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment