php - WordPress : Password Protected Page -
php - WordPress : Password Protected Page -
i need help regards wordpress password protect page/s.
after inputting password, redirected same page entered or showing content after inputting password.
what want that, after input right password, redirects page of site. how possible? much possible, won't using plugins.
below code functions.php:
<?php function my_password_form() { global $post; $label = 'pwbox-'.(empty($post->id) ? rand() : $post->id); $output = '<form action="' . get_option('siteurl') . '/wp-pass.php" method="post"> <p><strong>'.__("cakes").'</strong></p> <p>' . __("this page password-protected. please input password below.") . '</p> <center><label for="' . $label . '">' . __("password:") . '<input name="post_password" id="' . $label . '" type="password" size="40" style="height:20px;"/></label><input type="image" src="images/btn_member02.png" name="submit" value="' . esc_attr__("submit") . '"/></center> </form> '; homecoming $output; } add_filter('the_password_form', 'my_password_form'); ?> as example, when input right password on page www.mysite.com/memberlogin, should redirected www.mysite.com/memberpage.
i have write next code problem. please check next code may useful ( write code in functions.php ):-
<?php add_action( 'login_form_postpass', 'redirectpasswordprotectedpage' ); function redirectpasswordprotectedpage() { if ( ! empty( $_post['post_password'] ) ) { /** @var wpdb $wpdb */ global $wpdb; $query = $wpdb->prepare( "select * $wpdb->posts post_password = %s", trim($_post['post_password']) ); $password_posts = $wpdb->get_row( $query ); if ( isset( $password_posts ) ) { $post_id = $password_posts->id; wp_safe_redirect(get_permalink(25)); exit; } } } ?> php wordpress redirect passwords
Comments
Post a Comment