BP_REST_Forums_Endpoint::prepare_password_response( string $password )

Prepare response for the password protected posts.

Description

Parameters

$password

(string) (Required) WP_Post password.

Return

(mixed)

Source

File: bp-forums/classes/class-bp-rest-forums-endpoint.php

	public function prepare_password_response( $password ) {
		if ( ! empty( $password ) ) {
			/**
			 * Fake the correct cookie to fool post_password_required().
			 * Without this, get_the_content() will give a password form.
			 */
			require_once ABSPATH . 'wp-includes/class-phpass.php';

			$hasher                                 = new PasswordHash( 8, true );
			$value                                  = $hasher->HashPassword( $password );
			$_COOKIE[ 'wp-postpass_' . COOKIEHASH ] = wp_slash( $value );
		}

		return $password;
	}

Questions?

We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.