bookmark_borderGF_User_Registration

GF_User_Registration is the class which houses the main functionality of the Gravity Forms User Registration Add-on, it extends the GFFeedAddOn class which is part of the add-on framework. Below are a few functions which you may find useful when working on your own custom code.

gf_user_registration()

The gf_user_registration() function is used to return an instance of the GF_User_Registration class.

maybe_process_feed()

Triggers processing of the User Registration feeds for the specified form and entry objects.

$entry = gf_user_registration()->maybe_process_feed( $entry, $form );

get_single_submission_feed()

Retrieves the feed for the specified form and entry objects.

$feed = gf_user_registration()->get_single_submission_feed( $entry, $form );
  • $entry Entry Object

    The Entry Object to be processed.

  • $form

    The Form Object to be processed.

  • Returns Feed Object|boolean

    The feed which was used to process the supplied entry object or false if a feed wasn’t processed for the entry and an active feed with matching conditional logic could not be found.

get_meta_value()

Retrieves the value to be used for the specified meta key.

$value = gf_user_registration()->get_meta_value( $meta_key, $meta, $form, $entry );
  • $meta_key string

    The meta key for the field which was mapped when configuring the feed.

  • $meta User Registration Feed Meta

    The array containing the feed properties.

  • $form

    The Form Object being processed.

  • $entry Entry Object

    The Entry Object being processed.

  • Returns string

    The value matching the meta mapping for the given meta key or if not found, an empty string

add_validation_error()

Useful when performing custom validation using the gform_user_registration_validation filter to add a custom validation error message.

$form = gf_user_registration()->add_validation_error( $field_id, $form, $message );
  • $field_id integer

    The ID of the field the validation error should be applied to.

  • $form

    The Form Object to be processed.

  • $message string

    The validation message to be applied to the field.

  • Returns

get_user_by_entry_id()

Retrieve the user object or id for the user which was created or updated by the supplied entry id.

$user    = gf_user_registration()->get_user_by_entry_id( $entry_id );
$user_id = gf_user_registration()->get_user_by_entry_id( $entry_id, true );
  • $entry_id integer

    The ID of the entry the user was created or updated from.

  • $id_only boolean

    Defaults to false. Indicates if the user ID should be returned instead of the full WP_User object

  • Returns boolean|integer|WP_User

    False if a user wasn’t created or updated from the entry, or the user id or WP_User object.

get_site_by_entry_id()

Retrieve the id of the site which was created or updated by the supplied entry id.

$site = gf_user_registration()->get_site_by_entry_id( $entry_id );
  • $entry_id integer

    The ID of the entry the user was created or updated from.

  • Returns boolean|integer

    False if a site wasn’t created or updated from the entry, or the site id.

insert_feed()

The insert_feed() method can be used to add User Registration feeds.

$feed_id = gf_user_registration()->insert_feed( $form_id, $is_active, $meta );
  • $form_id integer

    The ID of the form this feed will be used with.

  • $is_active boolean

    Is this feed active or inactive.

  • $meta User Registration Feed Meta

    An associative array containing the properties which determine if a user will be updated or created when the feed is processed.

  • Returns integer

    The ID of the new feed.

add_note()

Add a note to the specified Entry.

gf_user_registration()->add_note( $entry_id, $note, $note_type );
  • $entry_id integer

    The ID of the Entry this note should be added to.

  • $note string

    The note to be added.

  • $note_type string

    The type of note to be added. Example values: note, success, or error

log_debug()

Writes a debug message to the log file for the User Registration Add-On. Requires the logging add-on.

gf_user_registration()->log_debug( $message );
  • $message string

    The message to be written to the User Registration log.

log_error()

Writes an error message to the log file for the User Registration Add-On. Requires the logging add-on.

gf_user_registration()->log_error( $message );
  • $message string

    The message to be written to the User Registration log.