Restrict Content Pro
rcp_before_form_errors
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
Runs before RCP’s built-in validation in two places:
- Login (
rcp_process_login()) — one argument: posted login data, before username/password checks and rcp_login_form_errors. - Registration (
rcp_process_registration()) — two arguments: posted registration data and the current user’sRCP_Customerobject when logged in (may be empty for brand-new signups), before membership-level and gateway validation.
Use the third argument add_action only when you need the registration signature (10, 2).
Parameters
$posted_data (array) – Raw $_POST from the login or registration request.
$customer (RCP_Customer|false) – Registration only. Customer record for the logged-in user, if one exists.
Examples
function mytheme_rcp_before_login_form_errors( $posted_data ) {
// Login: use error group 'login'.
}
add_action( 'rcp_before_form_errors', 'mytheme_rcp_before_login_form_errors', 10, 1 );
function mytheme_rcp_before_register_form_errors( $posted_data, $customer ) {
if ( empty( $_POST['rcp_company'] ) ) {
rcp_errors()->add( 'missing_company', __( 'Company is required.', 'mytheme' ), 'register' );
}
}
add_action( 'rcp_before_form_errors', 'mytheme_rcp_before_register_form_errors', 10, 2 );
Related: rcp_form_errors, Creating Custom Registration Fields.