cliff
6/2/2017 - 4:50 PM

Redirect Community Events' login form to your own login form. Requires Community Events 4.4.7 (June 1, 2017) or later.

Redirect Community Events' login form to your own login form. Requires Community Events 4.4.7 (June 1, 2017) or later.

<?php
/**
 * Redirect Community Events' login form to your own login form. Requires Community Events 4.4.7 (June 1, 2017) or later.
 *
 * You may want to consider redirecting successful logins to the Community Events' Add New form or My Events list.
 * For prior versions of Community Events, reference https://gist.github.com/cliffordp/75d45b7508b881abdf0b60d3aa677ecf
 *
 * From: https://gist.github.com/cliffordp/c78a2ca22a6f231abb5754540a5f86f4
 *
 * @link https://developer.wordpress.org/reference/functions/esc_url_raw/
 * @link https://secure.php.net/manual/en/function.filter-var.php
 * @link https://developer.wordpress.org/reference/functions/wp_redirect/
 */
function cliff_ce_login_redirect_to_custom_login_url() {
	// !!! enter your full URL here (including HTTP or, ideally, HTTPS) !!!
	$redirect_to = '';

	$redirect_to = esc_url_raw( $redirect_to );

	if ( false === filter_var( $redirect_to, FILTER_VALIDATE_URL ) ) {
		return;
	}

	// 301 is permanent. 302 is temporary.
	// https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#3xx_Redirection
	// function's default is 302
	wp_redirect( esc_url_raw( $redirect_to ) );
	exit;
}
add_action( 'tribe_community_before_login_form', 'cliff_ce_login_redirect_to_custom_login_url' );