Skip to content

How to Password-Protect a Post

To password-protect a post, you need to give the option to the users. So to that, insert a text field in the form with the meta key post_password and insert this code snippet in your themes functions.php

How to password protect a post

[php] /**
* Set password for a post
*
* @param array $args
* @return array
*/
function wpufe_post_passowrd( $args ) {
if ( isset( $_POST[‘post_password'] ) ) {
$args[‘post_password'] = $_POST[‘post_password'];
}

return $args;
}

add_filter( ‘wpuf_add_post_args', ‘wpufe_post_passowrd' );
add_filter( ‘wpuf_update_post_args', ‘wpufe_post_passowrd' );
[/php]

WAIT! Don’t Miss Our Biggest Sale of the Year!

BlackFriday

EarlyDeals

Save Up To

81%

on weDevs Products

Hurry! This massive deal disappears when the timer runs out.

00Days00Hour00Min00Sec
Claim Yours & Save Up To 81%