Hey folks,
I am trying to write a function that redirects users to their own page upon login. There is an action for wp-members that does this. It works fine for a static url but my problem is that I can't seem to grab the current user's ID from within functions.php at the time that this filter runs.
I have simplified what I'm trying to do below, in order to pare this down to just the issue at hand.
add_filter( 'wpmem_login_redirect', 'my_login_redirect' ); //this filter is part of the wp-members plugin
function my_login_redirect()
{
$myuserid = get_current_user_id();
// this is ideally supposed to return the url that the login should redirect to
// it redirects okay but it inserts a 0 at the end instead of the user id.
}
Here are some others I have already tried --
wp_get_current_user(); then $current_user->ID //returns 0
global $user_ID; // also returns 0
Could this filter be running somehow before the user is officially logged in? Not sure how to find out.
Is there a native wordpress hook that I can use instead?
Appreciate any help! Thanks!
-barbara-