SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What Does The Last Line Of Code Do

    Hi, can some one tell me what the last line of code does: add_filter( 'login_redirect', 'redirect_user_to', 10, 3 );

    PHP Code:
    <?php

    // add this to the bottom of the functions.php file in yourt theme directory

    function redirect_user_to$redirect_to$user ) {
        global 
    $user;

        if ( 
    $user->user_login == 'member' ) {
            
    $redirect_to '/'// redirect to home page
            
    return $redirect_to;
        }

        return 
    $redirect_to;
    }
    add_filter'login_redirect''redirect_user_to'10);

    ?>

  2. #2
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    add_filter is built in function of wordpress which is used to add Hooks . In simple word above code will invoke method redirect_user_to once user login and redirect to next URL happen. From the code of redirect_user_to it seems that it check if current logged in user is member then redirect it to home page or else redirect to page from which he was initially redirected to Login page. Hope this helps you.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by facebookdev View Post
    add_filter is built in function of wordpress which is used to add Hooks . In simple word above code will invoke method redirect_user_to once user login and redirect to next URL happen. From the code of redirect_user_to it seems that it check if current logged in user is member then redirect it to home page or else redirect to page from which he was initially redirected to Login page. Hope this helps you.
    Thanks, what is the 10 and 3

  4. #4
    SitePoint Member
    Join Date
    Mar 2008
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    If you check the wordpress document then it will be clear that 10 is priority and 3 is number of argument for your hook method.

  5. #5
    SitePoint Addict
    Join Date
    Sep 2011
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok thanks for your help


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •