groundhogg/should_convert_user_to_contact_when_user_registered

πŸ“… Published on

πŸ“ Last updated

Documentation

Β»

Filter Hooks

Β»

groundhogg/should_convert_user_to_contact_when_user_registered

Filters whether a newly registered WordPress user should automatically be converted to a Groundhogg contact. Return false to prevent automatic contact creation for certain user roles or registration sources.

apply_filters( 'groundhogg/should_convert_user_to_contact_when_user_registered', $should, $user_id, $user );

You will receive the default boolean, the new user’s ID, and the WP_User object.

Example

add_filter( 'groundhogg/should_convert_user_to_contact_when_user_registered', 'my_extension_skip_admin_users', 10, 3 );

/**
 * Do not auto-create contacts for administrators.
 *
 * @param bool     $should
 * @param int      $user_id
 * @param \WP_User $user
 *
 * @return bool
 */
function my_extension_skip_admin_users( $should, $user_id, $user ) {
    if ( in_array( 'administrator', $user->roles ) ) {
        return false;
    }

    return $should;
}

Was this helpful?

Let us know if this document answered your question. That’s the only way we can improve.