95 lines
2.3 KiB
PHP
95 lines
2.3 KiB
PHP
<?php
|
|
|
|
function redirect_login_page() {
|
|
|
|
if( is_page( 'log-in' ) && is_user_logged_in() ) {
|
|
nocache_headers();
|
|
wp_redirect( home_url() );
|
|
//header('Refresh:0; url=' . home_url());
|
|
|
|
exit;
|
|
}
|
|
|
|
}
|
|
add_action( 'template_redirect', 'redirect_login_page' );
|
|
|
|
|
|
|
|
function custom_email_validation_filter( $result, $tag ) {
|
|
if ( 'email' == $tag->name ) {
|
|
|
|
$your_email = isset( $_POST['email'] ) ? trim( $_POST['email'] ) : '';
|
|
|
|
if ( email_exists( $your_email ) ) {
|
|
$result->invalidate( $tag, 'Este e-mail já está cadastrado.' );
|
|
}
|
|
|
|
}
|
|
|
|
return $result;
|
|
}
|
|
|
|
|
|
|
|
//Função para checar se os dados de novos usuários foram atualizas conforme o FORM de registro
|
|
function sige_check_user_meta( $user_login, $user )
|
|
{
|
|
|
|
$eh_militar = get_metadata( 'user', $user->ID, 'militar', true );
|
|
if ( $eh_militar != "" ){
|
|
return;
|
|
}
|
|
else
|
|
{
|
|
sige_metadata_to_user($user->ID);
|
|
}
|
|
|
|
}
|
|
add_action('wp_login', 'sige_check_user_meta', 10, 2);
|
|
|
|
|
|
function my_theme_enqueue_styles() {
|
|
wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
|
|
}
|
|
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
|
|
|
|
//Call Termo e Compartilha
|
|
//add_action('wp_footer', 'check_termo_compartilha');
|
|
//function check_termo_compartilha()
|
|
//{
|
|
|
|
// $id = get_the_ID();
|
|
// if ($id != 6021)
|
|
// echo do_shortcode('[check_termo]');
|
|
//
|
|
//};
|
|
|
|
/*
|
|
function my_wp_nav_menu_args( $args = '' ) {
|
|
|
|
if( is_user_logged_in() ) {
|
|
$args['menu'] = 'Sige 2021';
|
|
} else {
|
|
$args['menu'] = 'Principal';
|
|
}
|
|
return $args;
|
|
}
|
|
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );*/
|
|
|
|
function custom_login_footer() {
|
|
?>
|
|
<script type="text/javascript">
|
|
document.addEventListener('DOMContentLoaded', function() {
|
|
// Find the register link
|
|
var registerLink = document.querySelector('#nav a[href*="wp-login.php?action=register"]');
|
|
if (registerLink) {
|
|
// Change the URL
|
|
registerLink.href = '<?php echo esc_url(site_url('https://www.sige.ita.br/?ff_landing=10/')); ?>';
|
|
// Optionally, change the text
|
|
registerLink.textContent = 'Custom Register';
|
|
}
|
|
});
|
|
</script>
|
|
<?php
|
|
}
|
|
add_action('login_footer', 'custom_login_footer');
|