Tagged: 3rd-Party Plugin, WordPress
-
AuthorPosts
-
May 3, 2023 at 3:51 pm #87516ShawnGuest
Since I couldn’t get the function script to work with PPWP plugin, I was able to modify this script to map the page id with a specific gravity form id. This works a charm – allows me to have multiple forms with multiple pw protected pages. Would be nice if you added this to your tutorial for future users.
https://codeshare.io/xv3nYN (24h link)
/*custom pw protected page*/ /* https://www.boldgrid.com/support/wordpress-tutorials/edit-the-wordpress-password-protected-page/ */ function my_custom_password_form() { global $post; $label = 'pwbox-' . ( empty( $post->ID ) ? rand() : $post->ID ); $output = ''; $page_id = get_the_ID(); // Get the current page ID // Define an array that maps page IDs to form IDs $form_map = array( 6844 => 8, // Map page ID 6844 to form ID 8 2198 => 9, // Map page ID 2198 to form ID 9 6990 => 9, // Map post ID 6990 to form ID 9 // Add more mappings here as needed ); if ( isset( $form_map[$page_id] ) ) { // If the current page ID is in the map, get the corresponding form ID $form_id = $form_map[$page_id]; $output .= ' <div class="boldgrid-section"> <div class="container" style="text-align:center;"> <form action="' . esc_url( site_url( 'wp-login.php?action=postpass', 'login_post' ) ) . '" class="form-inline post-password-form" method="post"> <p>' . __( 'To view page, please enter your code below:' ) . '</p> <label for="' . $label . '">' . __( 'Password:' ) . ' <input name="post_password" id="' . $label . '" type="password" size="20" class="form-control" /></label><button type="submit" name="Submit" class="button-primary">' . esc_attr_x( 'Enter', 'post password form' ) . '</button> </form> </div> <div style="width:50%; margin:0 auto;"> <hr> <h2>Request code</h2> [gravityform id="' . $form_id . '" title="false" description="false" ajax="true"] </div> </div> '; } else { // If the page ID is not in the map, return a 404 error $output = "404"; } // Return the output return $output; } add_filter('the_password_form', 'my_custom_password_form', 99); /*END pw*/
May 3, 2023 at 3:57 pm #87538Brandon CKeymasterHi Shawn,
We’ll definitely review your code and test with the PPWP plugin, Gravity forms and our BoldGrid products Crio Pro WordPress theme and BoldGrid Post and Page Builder for WordPress.
If we feel this is a needed implementation we will definitely create a new article or update the existing one with the new information.
We appreciate your for working on this and bringing it to our attention! Please let us know if there’s anything else that we can help with!
-
AuthorPosts
- The topic ‘Modified PW protect page to work with Gravity Forms’ is closed to new replies.