I’ve created a field “corso” with type field taxonomy/select html and in admin area the field is visible when user = subscriber.
In frontend, in archive.php I put a login form and after login if term is = “corso” of user, the user will see that term data. all is ok but I would like to redirect user after login getting the field.
$corso_id return id and I need the slug.
thank you very much
<?php
$corso_id = get_field('corso', 'user_'.$current_user->ID );
$term = $wp_query->queried_object;
$term_id = $term->term_id;
$term_name = $term->slug;
if (!is_user_logged_in()) {
$args = array(
'echo' => true,
'redirect' => get_option('siteurl').'/?corsi='.$XXXXXXX,
'form_id' => 'loginform',
'label_username' => __( 'Username' ),
'label_password' => __( 'Password' ),
'label_remember' => __( 'Remember Me' ),
'label_log_in' => __( 'Log In' ),
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'remember' => false,
'value_username' => NULL,
'value_remember' => false
);
wp_login_form( $args );
} else {
if ( $term_id == $corso_id || current_user_can('administrator') ) {
// corsi
} else {
// you can't see corsi
}
}
?>
Hi @donnafefe
You can do this to get the slug from the term id:
<?php
$corso_id = get_field('corso', 'user_'.$current_user->ID );
$corso_term = get_term($corso_id);
$corso_slug = $corso_term->slug;