Restrict Content Pro
rcp_after_register_form_fields
Coming soon: Restrict Content Pro is becoming Kadence Memberships. You may see both names used while we update the product, documentation, and customer experience.
Note: This content is provided as a resource within our developer documentation. Because custom code requires highly specific implementation, we encourage you to work with a qualified developer if you need guidance. You can find our recommended consultants here: https://codeable.io/developers/restrict-content-pro/
Used to add extra form fields to the end of the registration form. Fields added here are displayed directly above the gateway selection.
Use rcp_form_errors to validate form fields.
Example
This example adds a custom registration checkbox and sets an error if it is not checked.
/**
* Add a checkbox to the registration form.
*
* @return void
*/
function ag_rcp_after_register_form_fields() {
?>
<p>
<input name="rcp_sample_required_field" id="rcp_sample_required_field" type="checkbox" checked="checked" />
<label for="rcp_sample_required_field"><?php esc_html_e( 'Your field label*', 'rcp' ); ?></label>
</p>
<?php
}
add_action( 'rcp_after_register_form_fields', 'ag_rcp_after_register_form_fields' );
/**
* Validate form submission and add an error if the checkbox isn't checked.
*
* @param array $posted Array of information sent to the form.
*
* @return void
*/
function ag_rcp_form_errors( $posted ) {
if ( ! isset( $posted['rcp_sample_required_field'] ) ) {
rcp_errors()->add( 'sample_field_required', __( 'You must check this field', 'rcp' ), 'register' );
}
}
add_action( 'rcp_form_errors', 'ag_rcp_form_errors' );