I made a simple plugin from this <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference/login_redirect" rel="nofollow">example</a>:
It only works if you are already logged in.
Please try it - drop the plugin code in your WordPress plugins directory - activate it - <strong>make sure you are fully logged out</strong> - and it will only redirect you to the
if you have already logged in.
What do the <strong>10, 3</strong> represent anyway, in this case?
From the other examples on this website and other websites - people are making reference to the
instead of the global
and other information - but I do not see any full code that shows a full functioning copy paste plugin using these methods. I am not asking someone to do my work for me - I just would really need to see a full working example of this.
If you have a full working example that clearly shows all of the variable and values that are needed - can you please post it here?
Thank you very much.
I'm adding another example and then going to jump off a bridge - I haven't wasted so much time on something since I first began programming.
I don't understand how <strong>login_redirect</strong> can work - if I can't determine the users information at the time it is called.
Code:
<?php
/*
Plugin Name: Redirect on login
Plugin URI: some URI
Description: Custom Redirect on login
Author: Some Autor
Version: 1.0
Author URI: some URI
*/
function my_login_redirect($redirect_to, $request){
global $current_user;
get_currentuserinfo();
//is there a user to check?
if(is_array($current_user->roles))
{
//check for admins
if(in_array("administrator", $current_user->roles))
return home_url("/wp-admin/?administrator");
else
return home_url("?NOTadministrator");
}
}
add_filter("login_redirect", "my_login_redirect", 10, 3);
?>
It only works if you are already logged in.
Please try it - drop the plugin code in your WordPress plugins directory - activate it - <strong>make sure you are fully logged out</strong> - and it will only redirect you to the
Code:
/wp-admin/?administrator
What do the <strong>10, 3</strong> represent anyway, in this case?
From the other examples on this website and other websites - people are making reference to the
Code:
$user->ID
Code:
$user_ID
If you have a full working example that clearly shows all of the variable and values that are needed - can you please post it here?
Thank you very much.
I'm adding another example and then going to jump off a bridge - I haven't wasted so much time on something since I first began programming.
I don't understand how <strong>login_redirect</strong> can work - if I can't determine the users information at the time it is called.
Code:
function my_login_redirect(){
if($user->ID){
if($user->has_cap('manage_options')) {
return home_url("/wp-admin/?administrator");
}else{
return home_url("?NOTadministrator");
}
}else{
echo "WHY DOES $user->ID NOT HAVE ANY VALUE YET WHEN CALLING 'login_redirect'? How am I to decide where to send the user - if I do not know who the user is because - I can not get the user ID yet?!";
}
}
add_filter('login_redirect', 'my_login_redirect', 10, 3);