Restrict Content Pro

rcp_edit_membership_after

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 additional content to the Membership Details page. Go to Restrict → Memberships and open a membership. This hook runs at the end of that details table, so extra fields should be output as table rows.

Parameters

$membership (RCP_Membership) – Membership object.

Example

This example displays a text field with the value of the company membership meta key. See Membership Meta for the meta functions used here.

/**
 * Add a Company field to the Membership Details table.
 *
 * @param RCP_Membership $membership Membership object.
 *
 * @return void
 */
function ag_rcp_edit_membership_after( $membership ) {
	$meta_value = rcp_get_membership_meta( $membership->get_id(), 'company', true );
	?>
	<tr>
		<th scope="row" class="row-title">
			<label for="rcp-company"><?php esc_html_e( 'Company:', 'rcp' ); ?></label>
		</th>
		<td>
			<input type="text" name="rcp_company" id="rcp-company" value="<?php echo esc_attr( $meta_value ); ?>" />
		</td>
	</tr>
	<?php
}
add_action( 'rcp_edit_membership_after', 'ag_rcp_edit_membership_after' );

The code above only displays the custom field. Saving requires another callback. Hook rcp_action_edit_membership at priority 9 so it runs before Restrict Content Pro processes the form and redirects.

/**
 * Save the Company field from the Membership Details page.
 *
 * @return void
 */
function ag_rcp_save_custom_membership_field() {
	// Permission check. -- do not edit
	if ( ! wp_verify_nonce( $_POST['rcp_edit_membership_nonce'], 'rcp_edit_membership' ) ) {
		wp_die( __( 'Nonce verification failed.', 'rcp' ), __( 'Error', 'rcp' ), array( 'response' => 403 ) );
	}

	if ( ! current_user_can( 'rcp_manage_members' ) ) {
		wp_die( __( 'You do not have permission to perform this action.', 'rcp' ), __( 'Error', 'rcp' ), array( 'response' => 403 ) );
	}

	// Check which membership is being saved. -- do not edit
	if ( empty( $_POST['membership_id'] ) ) {
		wp_die( __( 'Invalid membership ID.', 'rcp' ), __( 'Error', 'rcp' ), array( 'response' => 400 ) );
	}

	$membership_id = absint( $_POST['membership_id'] );
	$membership    = rcp_get_membership( $membership_id );

	if ( empty( $membership ) ) {
		wp_die( __( 'Invalid membership.', 'rcp' ), __( 'Error', 'rcp' ), array( 'response' => 400 ) );
	}

	/*
	 * All checks are done. Now you can save your custom value.
	 * Edit this to customize your meta key and $_POST value key.
	 */
	if ( ! empty( $_POST['rcp_company'] ) ) {
		rcp_update_membership_meta( $membership->get_id(), 'company', sanitize_text_field( $_POST['rcp_company'] ) );
	} else {
		rcp_delete_membership_meta( $membership->get_id(), 'company' );
	}
}
add_action( 'rcp_action_edit_membership', 'ag_rcp_save_custom_membership_field', 9 );
Last updated: September 11, 2026
Was this page helpful?
Thanks for the feedback!