0
I need to create a function in Wordpress so that when the user logs in automatically is redirected to another link, here is my code as is:
$user_id = get_current_user_id();
if ($user_id == 2) { //aqui adicionamos o ID do usuário cadastrado
function remove_menus(){
remove_menu_page( 'index.php' );
remove_menu_page( 'about.php' );
remove_menu_page( 'edit.php' );
remove_menu_page( 'upload.php' );
remove_menu_page( 'edit.php?post_type=page' );
remove_menu_page( 'edit-comments.php' );
remove_menu_page( 'themes.php' );
remove_menu_page( 'users.php' );
remove_menu_page( 'tools.php' );
remove_menu_page( 'options-general.php' );
remove_menu_page( 'admin.php?page=revslider' );
remove_menu_page( 'admin.php?page=wpcf7' );
remove_menu_page( 'admin.php?page=loco' );
}
//aqui é onde tento criar a função para fazer esse redirecionamento mais não funcionou
function realocar (){
if (isset($_POST[get_current_user_id == 2])){
$url = 'aqui vem o link pra redirecionar';
header("Location: $url");
}
}
add_action( 'admin_menu', 'remove_menus', 'realocar' );
} else {
}
Avoid touching the wordpress code directly. If you do not know what you are doing ends up breaking the script or loses everything in an update or worse. Try using a plugin, like this one: https://br.wordpress.org/plugins/redirect-after-login/ But if you have to tweak it, then you have to add a filter in wp-login.php
– Rene Freak
@Renefreak I am creating a plugin to do this, otherwise my work may get lost in any WP update that comes up.
– WPfan