I created a redirect for my users of a certain user role the first time they log in. This is working as intended. See code:
[code]// Login redirect 1st login
//hook when user registers
add_action( 'user_register', 'myplugin_registration_save', 10, 1 );
function myplugin_registration_save( $user_id ) {
// insert meta that user not logged in first time
update_user_meta($user_id, 'prefix_first_login', '1');
}
// hook when user logs in
add_action('wp_login', 'your_function', 10, 2);
function your_function($user_login, $user) {
$user_id = $user->ID;
$role = $user->roles[0];
// getting prev. saved meta
$first_login = get_user_meta($user_id, 'prefix_first_login', true);
// if first time login
if( ($first_login == '1' ) && ($role == 'vakman')) {
// update meta after first login
update_user_meta($user_id, 'prefix_first_login', '0');
// redirect to given URL
wp_redirect( 'hidden link' );
exit;
}
}[/code]
However I actually want the user to land on the "edit user form". But the URL for it contains the user's name. Like so domain.com/slug/user-name/content-template-id=587 and adding the form to a page doesn't show the form ofcourse. How could I best tackle this?
Also is it possible for a user to see a message the first time they land on this page?