WordPress Core provides a lot of helper functions to accomplish these types of tasks. If it’s not a function, then there most often is a filter or action that you can hook into.
In the case of the WordPress login form, it’s wp_login_form()
. Here documentation on that:
https://codex.wordpress.org/Function_Reference/wp_login_form
Regarding redirecting users after login, there’s a filter for that. This code is a snippet I’ve used on many sites:
function wip_login_redirect( $url, $request, $user ){
$slug = $_SERVER["REQUEST_URI"];
$islogin = strpos($slug, 'log-in');
if( $user && is_object( $user ) && is_a( $user, 'WP_User' ) ) {
if(($user->has_cap('edit_users')) && ($islogin==true)) {
$url = admin_url('index.php');
} elseif ((!$user->has_cap('edit_users')) && ($islogin==true)) {
$url = home_url();
} else {
$url = $slug;
}
}
return $url;
}
add_filter('login_redirect', 'wip_login_redirect', 10, 3 );
I go into detail about that in this article:
https://wordimpress.com/conditional-custom-login-redirects-wordpress/
Hope that gets you going in the right direction.