wpf_user_register

wpf_user_register

#Overview
This filter allows you to modify any user meta data captured at registration, before a new contact record is created in your crm. To use the code examples below, add them to your active theme』s functions.php file.
#Parameters

$user_meta: Array of user meta data collected at registration, in the format array('meta_field' => 'value').
$user_id: ID for the user being updated.

#Examples
#Correct an invalid input field name on a registration form
Some plugins allow you to add custom fields to registration forms via code, but the 「name」 value of the input isn』t the same as the meta field in the database. For example, you may have added the field my_custom_field to the form, but in the database (and WP Fusion』s Contact Fields settings) the field is myplugin_my_custom_field. Since WP Fusion is looking for the meta key value as it』s set in the database, it won』t be detected on the registration form.
To correct this, you can use the wpf_user_register filter like so:
function my_wpf_filter_registration( $user_meta, $user_id ) {

if( isset( $user_meta['my_custom_field'] ) ) {
$user_meta['myplugin_my_custom_field'] = $user_meta['my_custom_field'];
}

return $user_meta;

}

add_filter( 'wpf_user_register', 'my_wpf_filter_registration', 10, 2 );

#Preventing a user from being synced to the CRM
If you return null from the wpf_user_register filter, WP Fusion will not create a contact record in your CRM.
In this example we prevent a contact record from being created at registration if the user has the author role:
function my_wpf_filter_registration( $user_meta, $user_id ) {

$user = get_userdata( $user_id );

if ( in_array( 'author', (array) $user->roles ) ) {
return null;
}

return $user_meta;

}

add_filter( 'wpf_user_register', 'my_wpf_filter_registration', 10, 2 );

#Was this helpful?

Let us know if you liked the post. That』s the only way we can improve.

Yes

No

發表回覆

您的郵箱地址不會被公開。 必填項已用 * 標註