WordPress.org

Ready to get started?Download WordPress

Forums

password protection function (2 posts)

  1. astima
    Member
    Posted 2 years ago #

    I know you can make a post password-protected if you select that option when creating a post. The issue I am having is that I want to post via e-mail and I have to go back and change this setting each time. Which of course defeats the purpose of posting via e-mail.

    I am trying to find the function for the password protect option to see I can somehow change it to make all posts in a certain category password-protected. Does anyone know where I can find this function?

    Thanks

  2. astima
    Member
    Posted 2 years ago #

    I think I found the functioning, but not sure if I am entering the right code. I want all posts that appear in category 12 to automatically be password-protected. I will be posting to this category via e-mail and don't want to have to go in each time and select this option. Below is my altered code. Is that correct?

    function post_password_required( $post = null ) {
    	$post = get_post($post);
    
    	if ( empty($post->post_password) )
    		return false;
    	if is_category( '12' )
    		return true;
    
    	if ( !isset($_COOKIE['wp-postpass_' . COOKIEHASH]) )
    		return true;
    
    	if ( stripslashes( $_COOKIE['wp-postpass_' . COOKIEHASH] ) != $post->post_password )
    		return true;
    
    	return false;
    }

Topic Closed

This topic has been closed to new replies.

About this Topic