Wordpress: how to set hook priority?










1















I have this function and hook to redirect a visitor right after the registration.



It doesn't work. As far as I see the code is right, then I guess that might be other plugin using the same plugin.



Is there a way to set the priority of my hook to override the other one?



function somlaw_registration_redirect() 
return home_url( '/my-page' );


add_filter( 'registration_redirect', 'somlaw_registration_redirect' );









share|improve this question


























    1















    I have this function and hook to redirect a visitor right after the registration.



    It doesn't work. As far as I see the code is right, then I guess that might be other plugin using the same plugin.



    Is there a way to set the priority of my hook to override the other one?



    function somlaw_registration_redirect() 
    return home_url( '/my-page' );


    add_filter( 'registration_redirect', 'somlaw_registration_redirect' );









    share|improve this question
























      1












      1








      1








      I have this function and hook to redirect a visitor right after the registration.



      It doesn't work. As far as I see the code is right, then I guess that might be other plugin using the same plugin.



      Is there a way to set the priority of my hook to override the other one?



      function somlaw_registration_redirect() 
      return home_url( '/my-page' );


      add_filter( 'registration_redirect', 'somlaw_registration_redirect' );









      share|improve this question














      I have this function and hook to redirect a visitor right after the registration.



      It doesn't work. As far as I see the code is right, then I guess that might be other plugin using the same plugin.



      Is there a way to set the priority of my hook to override the other one?



      function somlaw_registration_redirect() 
      return home_url( '/my-page' );


      add_filter( 'registration_redirect', 'somlaw_registration_redirect' );






      wordpress






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 15 '18 at 9:35









      JPashsJPashs

      4,03382028




      4,03382028






















          4 Answers
          4






          active

          oldest

          votes


















          2














          add_filter Format like this,






          add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )





          For E.g.






          // Accepting two arguments (three possible).
          function example_callback( $value, $arg2 )
          ...
          return $maybe_modified_value;

          add_filter( 'hook', 'example_callback', 10, 2 ); // Where $priority is 10, $accepted_args is 2.





          In your code, you can set the priority as like,






          function somlaw_registration_redirect() 
          return home_url( '/my-page' );

          add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5, 2 );





          Get more details: https://developer.wordpress.org/reference/functions/add_filter/






          share|improve this answer






























            1














            Try This:



            function somlaw_registration_redirect() 
            return home_url( '/my-page' );

            add_filter( 'registration_redirect', 'somlaw_registration_redirect',3);


            add_filter accepts the 3rd argument as priority. Default value is 10 so enter any value lower then 10 to set the priority.






            share|improve this answer






























              0














              Try



              add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5 );


              The last digit 5 is the priority. Default is 10. You can lower it further and check which number works for you.






              share|improve this answer






























                0














                Try passing argument in the function alongwith setting priority :



                function somlaw_registration_redirect( $redirect_url ) 
                return home_url( '/my-page' );

                add_filter( 'registration_redirect', 'somlaw_registration_redirect', 3 );


                Note: Also try changing the priority.






                share|improve this answer






















                  Your Answer






                  StackExchange.ifUsing("editor", function ()
                  StackExchange.using("externalEditor", function ()
                  StackExchange.using("snippets", function ()
                  StackExchange.snippets.init();
                  );
                  );
                  , "code-snippets");

                  StackExchange.ready(function()
                  var channelOptions =
                  tags: "".split(" "),
                  id: "1"
                  ;
                  initTagRenderer("".split(" "), "".split(" "), channelOptions);

                  StackExchange.using("externalEditor", function()
                  // Have to fire editor after snippets, if snippets enabled
                  if (StackExchange.settings.snippets.snippetsEnabled)
                  StackExchange.using("snippets", function()
                  createEditor();
                  );

                  else
                  createEditor();

                  );

                  function createEditor()
                  StackExchange.prepareEditor(
                  heartbeatType: 'answer',
                  autoActivateHeartbeat: false,
                  convertImagesToLinks: true,
                  noModals: true,
                  showLowRepImageUploadWarning: true,
                  reputationToPostImages: 10,
                  bindNavPrevention: true,
                  postfix: "",
                  imageUploader:
                  brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                  contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                  allowUrls: true
                  ,
                  onDemand: true,
                  discardSelector: ".discard-answer"
                  ,immediatelyShowMarkdownHelp:true
                  );



                  );













                  draft saved

                  draft discarded


















                  StackExchange.ready(
                  function ()
                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316341%2fwordpress-how-to-set-hook-priority%23new-answer', 'question_page');

                  );

                  Post as a guest















                  Required, but never shown

























                  4 Answers
                  4






                  active

                  oldest

                  votes








                  4 Answers
                  4






                  active

                  oldest

                  votes









                  active

                  oldest

                  votes






                  active

                  oldest

                  votes









                  2














                  add_filter Format like this,






                  add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )





                  For E.g.






                  // Accepting two arguments (three possible).
                  function example_callback( $value, $arg2 )
                  ...
                  return $maybe_modified_value;

                  add_filter( 'hook', 'example_callback', 10, 2 ); // Where $priority is 10, $accepted_args is 2.





                  In your code, you can set the priority as like,






                  function somlaw_registration_redirect() 
                  return home_url( '/my-page' );

                  add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5, 2 );





                  Get more details: https://developer.wordpress.org/reference/functions/add_filter/






                  share|improve this answer



























                    2














                    add_filter Format like this,






                    add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )





                    For E.g.






                    // Accepting two arguments (three possible).
                    function example_callback( $value, $arg2 )
                    ...
                    return $maybe_modified_value;

                    add_filter( 'hook', 'example_callback', 10, 2 ); // Where $priority is 10, $accepted_args is 2.





                    In your code, you can set the priority as like,






                    function somlaw_registration_redirect() 
                    return home_url( '/my-page' );

                    add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5, 2 );





                    Get more details: https://developer.wordpress.org/reference/functions/add_filter/






                    share|improve this answer

























                      2












                      2








                      2







                      add_filter Format like this,






                      add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )





                      For E.g.






                      // Accepting two arguments (three possible).
                      function example_callback( $value, $arg2 )
                      ...
                      return $maybe_modified_value;

                      add_filter( 'hook', 'example_callback', 10, 2 ); // Where $priority is 10, $accepted_args is 2.





                      In your code, you can set the priority as like,






                      function somlaw_registration_redirect() 
                      return home_url( '/my-page' );

                      add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5, 2 );





                      Get more details: https://developer.wordpress.org/reference/functions/add_filter/






                      share|improve this answer













                      add_filter Format like this,






                      add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )





                      For E.g.






                      // Accepting two arguments (three possible).
                      function example_callback( $value, $arg2 )
                      ...
                      return $maybe_modified_value;

                      add_filter( 'hook', 'example_callback', 10, 2 ); // Where $priority is 10, $accepted_args is 2.





                      In your code, you can set the priority as like,






                      function somlaw_registration_redirect() 
                      return home_url( '/my-page' );

                      add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5, 2 );





                      Get more details: https://developer.wordpress.org/reference/functions/add_filter/






                      add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )





                      add_filter( string $tag, callable $function_to_add, int $priority = 10, int $accepted_args = 1 )





                      // Accepting two arguments (three possible).
                      function example_callback( $value, $arg2 )
                      ...
                      return $maybe_modified_value;

                      add_filter( 'hook', 'example_callback', 10, 2 ); // Where $priority is 10, $accepted_args is 2.





                      // Accepting two arguments (three possible).
                      function example_callback( $value, $arg2 )
                      ...
                      return $maybe_modified_value;

                      add_filter( 'hook', 'example_callback', 10, 2 ); // Where $priority is 10, $accepted_args is 2.





                      function somlaw_registration_redirect() 
                      return home_url( '/my-page' );

                      add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5, 2 );





                      function somlaw_registration_redirect() 
                      return home_url( '/my-page' );

                      add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5, 2 );






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Nov 15 '18 at 9:46









                      Priyanka ModiPriyanka Modi

                      1,0541611




                      1,0541611























                          1














                          Try This:



                          function somlaw_registration_redirect() 
                          return home_url( '/my-page' );

                          add_filter( 'registration_redirect', 'somlaw_registration_redirect',3);


                          add_filter accepts the 3rd argument as priority. Default value is 10 so enter any value lower then 10 to set the priority.






                          share|improve this answer



























                            1














                            Try This:



                            function somlaw_registration_redirect() 
                            return home_url( '/my-page' );

                            add_filter( 'registration_redirect', 'somlaw_registration_redirect',3);


                            add_filter accepts the 3rd argument as priority. Default value is 10 so enter any value lower then 10 to set the priority.






                            share|improve this answer

























                              1












                              1








                              1







                              Try This:



                              function somlaw_registration_redirect() 
                              return home_url( '/my-page' );

                              add_filter( 'registration_redirect', 'somlaw_registration_redirect',3);


                              add_filter accepts the 3rd argument as priority. Default value is 10 so enter any value lower then 10 to set the priority.






                              share|improve this answer













                              Try This:



                              function somlaw_registration_redirect() 
                              return home_url( '/my-page' );

                              add_filter( 'registration_redirect', 'somlaw_registration_redirect',3);


                              add_filter accepts the 3rd argument as priority. Default value is 10 so enter any value lower then 10 to set the priority.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Nov 15 '18 at 9:39









                              Darsh khakhkharDarsh khakhkhar

                              42929




                              42929





















                                  0














                                  Try



                                  add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5 );


                                  The last digit 5 is the priority. Default is 10. You can lower it further and check which number works for you.






                                  share|improve this answer



























                                    0














                                    Try



                                    add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5 );


                                    The last digit 5 is the priority. Default is 10. You can lower it further and check which number works for you.






                                    share|improve this answer

























                                      0












                                      0








                                      0







                                      Try



                                      add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5 );


                                      The last digit 5 is the priority. Default is 10. You can lower it further and check which number works for you.






                                      share|improve this answer













                                      Try



                                      add_filter( 'registration_redirect', 'somlaw_registration_redirect', 5 );


                                      The last digit 5 is the priority. Default is 10. You can lower it further and check which number works for you.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Nov 15 '18 at 9:39









                                      zipkundanzipkundan

                                      1,2661514




                                      1,2661514





















                                          0














                                          Try passing argument in the function alongwith setting priority :



                                          function somlaw_registration_redirect( $redirect_url ) 
                                          return home_url( '/my-page' );

                                          add_filter( 'registration_redirect', 'somlaw_registration_redirect', 3 );


                                          Note: Also try changing the priority.






                                          share|improve this answer



























                                            0














                                            Try passing argument in the function alongwith setting priority :



                                            function somlaw_registration_redirect( $redirect_url ) 
                                            return home_url( '/my-page' );

                                            add_filter( 'registration_redirect', 'somlaw_registration_redirect', 3 );


                                            Note: Also try changing the priority.






                                            share|improve this answer

























                                              0












                                              0








                                              0







                                              Try passing argument in the function alongwith setting priority :



                                              function somlaw_registration_redirect( $redirect_url ) 
                                              return home_url( '/my-page' );

                                              add_filter( 'registration_redirect', 'somlaw_registration_redirect', 3 );


                                              Note: Also try changing the priority.






                                              share|improve this answer













                                              Try passing argument in the function alongwith setting priority :



                                              function somlaw_registration_redirect( $redirect_url ) 
                                              return home_url( '/my-page' );

                                              add_filter( 'registration_redirect', 'somlaw_registration_redirect', 3 );


                                              Note: Also try changing the priority.







                                              share|improve this answer












                                              share|improve this answer



                                              share|improve this answer










                                              answered Nov 15 '18 at 10:28









                                              wpgeek1311wpgeek1311

                                              1




                                              1



























                                                  draft saved

                                                  draft discarded
















































                                                  Thanks for contributing an answer to Stack Overflow!


                                                  • Please be sure to answer the question. Provide details and share your research!

                                                  But avoid


                                                  • Asking for help, clarification, or responding to other answers.

                                                  • Making statements based on opinion; back them up with references or personal experience.

                                                  To learn more, see our tips on writing great answers.




                                                  draft saved


                                                  draft discarded














                                                  StackExchange.ready(
                                                  function ()
                                                  StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53316341%2fwordpress-how-to-set-hook-priority%23new-answer', 'question_page');

                                                  );

                                                  Post as a guest















                                                  Required, but never shown





















































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown

































                                                  Required, but never shown














                                                  Required, but never shown












                                                  Required, but never shown







                                                  Required, but never shown







                                                  這個網誌中的熱門文章

                                                  How to read a connectionString WITH PROVIDER in .NET Core?

                                                  Node.js Script on GitHub Pages or Amazon S3

                                                  Museum of Modern and Contemporary Art of Trento and Rovereto