![]() The GET method is restricted to send up to 2048 characters only.The variable names and values will be visible in URL if HTML forms submitted by the GET method.Let’s just code this into the functions.php for simplicity sake.PHP Overview PHP Tutorial PHP Introduction PHP Installation PHP Basics PHP Basics PHP Syntax PHP Data Types PHP Variables PHP Constants PHP Print and Echo Statements Operators PHP Operators PHP Arithmetic Operators PHP Assignment Operators PHP Comparison Operators PHP Logical Operators PHP Ternary Operator PHP Concatenation Operators Decision Control Structures PHP Decision Making PHP if else statement PHP elseif statement PHP switch statement Loop Control Structures PHP Looping PHP while loop PHP do-while PHP for loop PHP foreach loop Functions PHP Date and Time PHP Functions PHP String Handling Functions PHP Include and Require PHP Headers PHP File Handling PHP Cookies PHP Sessions PHP Sending Emails Compare Strings In PHP array_diff() Function in PHP array_merge() Function in PHP array_search() Function in PHP eval() in PHP preg_replace() Function in PHP URL Encoding and Decoding with PHP sleep() Function in PHP strlen() Function in PHP ksort() Function in PHP strlen() Function in PHP gettype() Function in PHP Forms PHP GET and POST PHP Server Side Form Validation PHP File Upload PHP Classes and Objects PHP OOP Terminology PHP Access Modifiers What is stdClass in PHP? PHP Inheritance PHP OOP Traits PHP Abstract Classes PHP Constructor PHP Destructor Miscellaneous PHP Arrays PHP RSS Feed PHP Composer Environment Variables in PHP PHP Error Handling We can either hook into the admin_post_* action via the functions.php of our theme, or we can create a simple plugin to handle the contact form. ![]() Actual Handling of the POST Requestįor this part, we have two options, and going with either one is fine. Notice that we are removing the POST processing function on top of the template since we are going to hook into the action later on. This is how the page template looks like after the modification: The simplest way to do this (not recommended) is perhaps to create a custom page template based on the basic page.php, hardcode a form and do the processing in that file itself. With this knowledge, we can easily hook into the appropriate actions to handle the contact form submission without actually messing with our theme template. ![]() These two actions will be triggered if the current user is not logged in:Īll the above four hooks are still available to you to use. Let’s say our POST request has an action with a value of foobar. Next, if ( ! wp_validate_auth_cookie() ), again based on the logged in state of the user. However, what we’re interested to go through in the context of this article will be only related to POST request. $action = empty( $_REQUEST ) ? '' : $_REQUEST ĭespite the name, admin-post.php can actually handle both of POST and GET requests. The current action is determined by this line of code: After that it sends an appropriate header and triggers the admin_init action. It starts by defining WP_ADMIN constant and then loading WordPress by requiring wp-load.php. Anatomy of admin-post.phpĪt the very basic level, admin-post.php only contains 71 lines of code. If you have experienced integrating your application with WordPress internal AJAX API, then you will notice that the basic structure of admin-post.php is not much different to the admin-ajax.php counterpart. This is possible by pointing all our form submissions to a specific file in the wp-admin directory called admin-post.php. All we need to know is the proper hooks needed for the POST request and to modify our code accordingly. It is no different with what we are going to achieve. ![]() Many plugins utilise these actions and filters to modify how WordPress works. Examples of actions that are running during program execution are init, wp, template_redirect and wp_head. This means internally, WordPress core is filled up with various actions and filters to modify the program execution or to alter the content during runtime. WordPress is based on an event driven architecture. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |