Member System - Source Excerpt 01
Summary
This source excerpt preserves a bounded section of Anti-Christ.net/wp-content/themes/anti-christ-thin-veil/inc/member-system.php so readers can inspect the evidence without opening the full source file.
**Source path:** Anti-Christ.net/wp-content/themes/anti-christ-thin-veil/inc/member-system.php
<?php
/**
* Theme-owned member system helpers.
*
* @package Anti_Christ_Thin_Veil
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* Required member age for the self-certification gate.
*
* @return int
*/
function actv_member_required_age() {
return 18;
}
/**
* Cookie name used by the age gate.
*
* @return string
*/
function actv_age_gate_cookie_name() {
return 'actv_age_gate_' . actv_member_required_age();
}
/**
* Cookie path for the age gate.
*
* @return string
*/
function actv_age_gate_cookie_path() {
return defined( 'COOKIEPATH' ) && COOKIEPATH ? COOKIEPATH : '/';
}
/**
* Return the current front-end URL.
*
* @return string
*/
function actv_current_url() {
$request_uri = isset( $_SERVER['REQUEST_URI'] ) ? esc_url_raw( wp_unslash( $_SERVER['REQUEST_URI'] ) ) : '/';
return home_url( $request_uri );
}
/**
* Resolve a safe redirect target for member forms.
*
* @param string $fallback Optional fallback URL.
* @return string
*/
function actv_member_redirect_target( $fallback = '' ) {
$target = '';
if ( isset( $_POST['actv_redirect_to'] ) ) {
$target = esc_url_raw( wp_unslash( $_POST['actv_redirect_to'] ) );
}
if ( ! $target && $fallback ) {
$target = $fallback;
}
if ( ! $target ) {
$target = wp_get_referer();
}
if ( ! $target ) {
$target = actv_page_url( 'members' );
}
return wp_validate_redirect( $target, actv_page_url( 'members' ) );
}
/**
* Determine whether this visitor has confirmed member age access.
*
* @return bool
*/
function actv_is_age_verified() {
if ( is_user_logged_in() && '1' === (string) get_user_meta( get_current_user_id(), 'actv_age_verified_18', true ) ) {
return true;
}
return isset( $_COOKIE[ actv_age_gate_cookie_name() ] ) && '1' === (string) $_COOKIE[ actv_age_gate_cookie_name() ];
}
/**
* Persist age self-certification.
*/
function actv_set_age_verified() {
$options = array(
'expires' => time() + YEAR_IN_SECONDS,
'path' => actv_age_gate_cookie_path(),
'secure' => is_ssl(),
'httponly' => true,
'samesite' => 'Lax',
);
if ( defined( 'COOKIE_DOMAIN' ) && COOKIE_DOMAIN ) {
$options['domain'] = COOKIE_DOMAIN;
}
setcookie( actv_age_gate_cookie_name(), '1', $options );
$_COOKIE[ actv_age_gate_cookie_name() ] = '1';
if ( is_user_logged_in() ) {
update_user_meta( get_current_user_id(), 'actv_age_verified_18', '1' );
}
}
/**
* Process the age gate form.
*/
function actv_handle_age_gate_confirmation() {
if ( 'POST' !== strtoupper( isset( $_SERVER['REQUEST_METHOD'] ) ? (string) $_SERVER['REQUEST_METHOD'] : '' ) ) {
return;
}
if ( ! isset( $_POST['actv_age_gate_action'] ) || 'confirm' !== sanitize_key( wp_unslash( $_POST['actv_age_gate_action'] ) ) ) {
return;
}
$redirect = actv_member_redirect_target();
$nonce = isset( $_POST['actv_age_gate_nonce'] ) ? sanitize_text_field( wp_unslash( $_POST['actv_age_gate_nonce'] ) ) : '';
if ( ! wp_verify_nonce( $nonce, 'actv_confirm_age_gate' ) ) {
wp_safe_redirect( add_query_arg( 'member_status', 'invalid', $redirect ) );
exit;
}
if ( empty( $_POST['actv_age_gate_confirm'] ) ) {
wp_safe_redirect( add_query_arg( 'member_status', 'age_required', $redirect ) );
exit;
}
actv_set_age_verified();
wp_safe_redirect( remove_query_arg( 'member_status', $redirect ) );
exit;
}
add_action( 'init', 'actv_handle_age_gate_confirmation', 5 );
/**
* Whether Loginizer is active on this install.
*
* @return bool
*/
function actv_loginizer_active() {
return defined( 'LOGINIZER_FILE' ) || defined( 'LOGINIZER_VERSION' );
}
/**
* Whether Participants Database shortcodes are available.
*
* @return bool
*/
function actv_participants_database_available() {
return shortcode_exists( 'pdb_signup' ) && shortcode_exists( 'pdb_record' );
}
/**
* Whether public WordPress user registration is enabled.
*
* @return bool
*/
function actv_wordpress_registration_open() {
return (bool) get_option( 'users_can_register' );
}
/**
* Configure Participants Database to use the theme-owned member record page.
*
* @param array $page_ids Starter page IDs keyed by slug.
*/
function actv_configure_participants_database_member_pages( $page_ids ) {
if ( ! class_exists( 'Participants_Db' ) || empty( $page_ids['member-record'] ) || ! method_exists( 'Participants_Db', 'update_plugin_setting' ) ) {
return;
}
$settings = array(
'registration_page' => (int) $page_ids['member-record'],
'show_retrieve_link' => '1',
);
if ( ! empty( $page_ids['join'] ) ) {
$settings['link_retrieval_page'] = (int) $page_ids['join'];
}
foreach ( $settings as $name => $value ) {
Participants_Db::update_plugin_setting( $name, $value );
if ( isset( Participants_Db::$plugin_options ) && is_array( Participants_Db::$plugin_options ) ) {
Participants_Db::$plugin_options[ $name ] = $value;
}
}
}
/**
* Fallback Participants Database record-page setting if the plugin has not been configured yet.
*
* @param mixed $setting Current plugin setting.
* @return mixed
*/
function actv_pdb_registration_page_fallback( $setting ) {
if ( '' !== (string) $setting && '0' !== (string) $setting && 'none' !== (string) $setting ) {
return $setting;
}
$page = get_page_by_path( 'member-record' );
return $page instanceof WP_Post ? (int) $page->ID : $setting;
}
add_filter( 'pdb-registration_page_setting_value', 'actv_pdb_registration_page_fallback' );
/**
* Render a status message for member redirects.
*
* @return string
*/
function actv_member_flash() {
$status = isset( $_GET['member_status'] ) ? sanitize_key( wp_unslash( $_GET['member_status'] ) ) : '';
$messages = array(
'age_required' => __( 'Confirm the 18+ member gate before continuing.', 'anti-christ-thin-veil' ),
'invalid' => __( 'The member form expired. Try again from this page.', 'anti-christ-thin-veil' ),
'login_required'=> __( 'Log in before submitting a dispatch.', 'anti-christ-thin-veil' ),
'missing' => __( 'Add a title, body, category, and rules confirmation before submitting.', 'anti-christ-thin-veil' ),
'rate_limited' => __( 'A dispatch was received recently. Wait a few minutes before sending another.', 'anti-christ-thin-veil' ),
'failed' => __( 'The dispatch could not be saved. Try again or use the contact protocol.', 'anti-christ-thin-veil' ),
'received' => __( 'Dispatch received for editorial review. It will not publish automatically.', 'anti-christ-thin-veil' ),
);
if ( ! isset( $messages[ $status ] ) ) {
return '';
}
$class = 'received' === $status ? 'member-alert is-success' : 'member-alert';
return '<div class="' . esc_attr( $class ) . '" role="status">' . esc_html( $messages[ $status ] ) . '</div>';
}
/**
* Render the 18+ self-certification gate.
*
* @param string $context Optional page context.
* @return string
*/
function actv_render_age_gate( $context = '' ) {
$redirect = actv_current_url();
$title = $context
? sprintf(
/* translators: %s is the member area context. */
__( 'Confirm 18+ access for %s', 'anti-christ-thin-veil' ),
$context
)
: __( 'Confirm 18+ member access', 'anti-christ-thin-veil' );
ob_start();
?>
<section class="age-gate-panel" aria-labelledby="age-gate-title">
<p class="section-label"><?php esc_html_e( 'Age gate', 'anti-christ-thin-veil' ); ?></p>
<h2 id="age-gate-title"><?php echo esc_html( $title ); ?></h2>
<p><?php esc_html_e( 'Member tools are for adults who will use this site for lawful civic writing, corrections, source leads, roster updates, and editorial submissions. This is a self-certification gate, not identity verification.', 'anti-christ-thin-veil' ); ?></p>
<form class="member-form compact-form" method="post" action="<?php echo esc_url( $redirect ); ?>">
<?php echo wp_nonce_field( 'actv_confirm_age_gate', 'actv_age_gate_nonce', true, false ); ?>
<input type="hidden" name="actv_age_gate_action" value="confirm">
<input type="hidden" name="actv_redirect_to" value="<?php echo esc_url( $redirect ); ?>">
<label class="checkbox-line">
<input type="checkbox" name="actv_age_gate_confirm" value="1" required>
<span>
<?php
printf(
/* translators: %d is the required age. */
esc_html__( 'I confirm I am %d or older and will not use this member system for threats, doxxing, illegal plans, harassment, hatred, stolen material, target lists, or calls for harm.', 'anti-christ-thin-veil' ),
(int) actv_member_required_age()
);
?>
</span>
</label>
<button class="button button-primary" type="submit"><?php esc_html_e( 'Enter member area', 'anti-christ-thin-veil' ); ?></button>
</form>
</section>
<?php
return ob_get_clean();
}