Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8487421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:14:01+00:00 2026-06-10T21:14:01+00:00

I made a simple plugin from this example : <?php /* Plugin Name: Redirect

  • 0

I made a simple plugin from this example:

<?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 – make sure you are fully logged out – and it will only redirect you to the /wp-admin/?administrator if you have already logged in.

What do the 10, 3 represent anyway, in this case?

From the other examples on this website and other websites – people are making reference to the $user->ID instead of the global $user_ID 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 login_redirect can work – if I can’t determine the users information at the time it is called.

     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);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:14:02+00:00Added an answer on June 10, 2026 at 9:14 pm
    • 10 represents the priority your function takes among the others filtering login_redirect
    • 3 represents the number of arguments your function accepts.

    See: http://codex.wordpress.org/Function_Reference/add_filter

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I made a very simple wordpress plugin that prints some posts in JSON format.
I made simple plugin and i would like to work this plugin only below
I have created a custom jQuery plugin that does some simple image resizing for
I have made simple encryption/decryption method in php that I'm trying to move to
so I'm making some basic programming language (just for exercise). I've made simple grammar
I've been developing a pretty simple WordPress plugin, and wanted to do some live
Is there a simple plugin or some robust code that would allow me to
I have made a very simple NSIS plugin that has one function in it.
I made simple email in wordpress but it would only send email to the
hi i've got question i've made simple form with attachment input and i want

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.