Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Replace content in WordPress Page after GET from php page

Reread your question and revised the solution as well. It is a Page template now and should be set to the page that needs its content protected. It relies on a “login” post that has the html from.

<?php
/*
Template Name: Protected Page
*/


// Standard HTML of Theme

    global $post;

    // check if authentication has been made
    if( verifyAuthentication($_POST['authCode']) ) {

        // display protected content
        the_content();
    }       
    else {

        // fetch the login form html from "login" post. Or you can read from a file or some admin settings of your plugin.
        $login_post = get_post( url_to_postid("login") );

        // display the html form
        echo apply_filters('the_content',$login_post->post_content );
    }


// Standard HTML of Theme

Post parameter authCode is supposed to be present and valid when login has been successfully authenticated.

Related Posts:

  1. Sending the reset password link programatically
  2. Getting only direct child pages in WordPress with get_pages
  3. Disable Attachment Pages Completely
  4. How to add a .php file to WordPress
  5. How to Remove all Instances of edit_post_link
  6. Any guides on creating custom admin pages?
  7. Need help setting default setting value for radio button in theme customizer
  8. Multiple is_page() in page.php
  9. Is having multiple theme customizers for different pages possible?
  10. Remove Customize Background and Header from Appearance admin menu without CSS or JS
  11. How to check if feed URL was requested?
  12. Create WordPress pages with PHP
  13. Is it possible to get a theme customizer setting from wp.customize using jquery?
  14. WordPress customizer: load controls in a custom div
  15. Dynamically change feature image in customiser
  16. One button to change all settings in theme customizer?
  17. Is it possible to generate a page without create in the admin?
  18. How to change “Shipping Calculator “field label on Cart Page – woocommerce? [closed]
  19. WordPress admin never finishes saving page on site with large page count
  20. class=”parent” for wp_list_pages?
  21. Check if Favicon is set in Customizer
  22. WordPress Customizer: How can you have multiple active callbacks on one control?
  23. PHP Script within wordpress theme
  24. Design view breaking on Pages
  25. add_rewrite_rule with bottom priority doesn’t handle the WordPress pages
  26. Dynamically loaded Theme components based on Customizer Settings values : changes not appearing in Customizer preview – (Workaround found)
  27. Listing all sub-pages?
  28. Customizer Show/Hide Logo and Site Title
  29. WordPress Customizer not setting default value upon initial install?
  30. How to add default images into theme customizer image control?
  31. Theme Customizer – Dynamic CSS PHP File
  32. How to link to a custom .php page in my folder
  33. Show different Customizer Settings on Page-Tamplates
  34. How to get custom image size for image uploaded in Customizer
  35. Get only the grandchildren, not the direct children of page/current page?
  36. Child and Parent Pages list of sub pages
  37. Allow user to choose header style
  38. Static Page with php echo [duplicate]
  39. Remove specific javascript when viewing page in Customizer?
  40. Customizer: How to Sanitize a Decimal Number Range
  41. How to update option field in database on clicking the publish button in customizer
  42. How to tell if a page has subpages for Custom Post Types
  43. loading a php file to a specific page id
  44. Getting page / post URL on publish and / or update
  45. Use page-templates without creating theme
  46. Get current_post in reverse order with pagination
  47. Make customizer panel or section button
  48. make an array in wordpress cusmization api?
  49. Multiple sections in Theme Customizer overwritten
  50. How to associate dynamic PHP page for chosen WordPress tag?
  51. Newbie question. Login/Registration. New PHP page
  52. Use Custiomizer to setup meta theme color tag
  53. Default Image not showing up in Customizer for WP_Customize_Cropped_Image_Control
  54. Sort on two variables
  55. Using get_theme_mod with checkbox to display content
  56. Adding my own custom template page but got white page
  57. customizer live preview layout picker
  58. Create a custom theme-specific page, invisible in the admin-panel?
  59. Access preview settings in php
  60. Create Customization Controls from Array
  61. List of child pages fetch next results at link click
  62. Execute php in pages
  63. Why isn’t my link attribute getting my css?
  64. How to map my php files as the files for pages
  65. How to use PHP code with wordpress page
  66. Show results for multiple page-types
  67. How to add feature image url in my template file and content as well?
  68. Display selected parts from selected pages on the frontpage?
  69. How to add button to top of theme customizer?
  70. How can I clear the theme mod settings?
  71. Cant get theme to change footer color through theme customizer
  72. Adding Media button to only pages
  73. Trying to put a search page on site
  74. I want Page titles and excerpts to show up on home.php in certain order
  75. wp_head makes my custom page template not work in Customizer?
  76. ACF: Echo page title when checkbox is checked
  77. Create a custom page URL
  78. How to refresh a template page on WordPress in 3 seconds – easiest method?
  79. Hide page title
  80. I can’t seem to get excerpts showing inside get_pages and don’t know why?
  81. Echo piece of code from file
  82. Forbid certain users to access a specific page
  83. How to return a Boolean for a page that is a subpage thru its name?
  84. How to handle parent and child pages?
  85. How do I remove blog entries from home page Twenty Eleven child theme?
  86. Create an if statement based on page_id
  87. How to store the_post_thumbnail() value in a variable
  88. PHP warning $post->ID is null
  89. hello can you advise how to fix the error?
  90. Sidebars panel in customizer
  91. Capture the Selected Radio Button Value between two files in wordpress theme
  92. WordPress Customizer – How to save list of checkbox of pages?
  93. WordPress Customizer add_control Dropdown of Pages with Multi Select?
  94. How do I create a single.php file as the default template for single posts in the twentytwentythree theme?
  95. Partial refresh in WordPress live preview
  96. Sections dependent on checkbox the WordPress WP_Customize_Control
  97. Show the terms of the hierarchical taxonomy
  98. Can’t find elemnts on the DOM using Custom Control in Customizer API
  99. WordPress post-template null warnings
  100. Custom theme on multisite has issues with standard loop output
Categories PHP Tags pages, php, remote-login, theme-customizer
Custom Post Status & Taxonomies
custom login form, guide me

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Post Navigation Elementor
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • WPFacet multiple loop displaying duplicate content
  • Get the name of the template/*html file used
  • Fix: WordPress.DB.PreparedSQL.NotPrepared Plugin Check (PCP)
  • Removing unnecessary CSS and JS code from wp_head()
  • hexagonal image gallery. Am I on the right track? [closed]
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress