I have a custom page where I ask users to log in to access the page. Once they log in, I would like to redirect them to the same page but I want to add on their user ID to the URL string in the redirect. This is just for analytics, the actual content is being protected by if (current_user_can('')){}
Here's the code I have tried in my password protected page:
<?php
$userID = get_current_user_id();
$args = array(
'echo' => true,
'remember' => true,
'redirect' => ( is_ssl() ? 'https://' : 'http://' ) . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?uid=' . $userID,
'form_id' => 'loginform',
'id_username' => 'user_login',
'id_password' => 'user_pass',
'id_remember' => 'rememberme',
'id_submit' => 'wp-submit',
'label_username' => __( 'Username or Email Address' ),
'label_password' => __( 'Password' ),
'label_remember' => __( 'Remember Me' ),
'label_log_in' => __( 'Log In' ),
'value_username' => '',
'value_remember' => false
);
wp_login_form($args);
?>
Obviously this won't work(returns "0") since it's trying to get the user's ID before they're logged in, but I can't think of how I would go about this.
if (current_user_can('')){}
They just want to be able to see the User ID in the page analytics, so I'm trying to pass the User ID into the URL on redirect.