BP_REST_Forums_Endpoint::prepare_password_response( string $password )

Prepare response for the password protected posts.

Description

Parameters

$password

(Required) WP_Post password.

Return

(mixed)

Source

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

1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
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.