create_new_application_password example

if ( is_wp_error( $user ) ) {
            return $user;
        }

        $prepared = $this->prepare_item_for_database( $request );

        if ( is_wp_error( $prepared ) ) {
            return $prepared;
        }

        $created = WP_Application_Passwords::create_new_application_password( $user->ID, wp_slash( (array) $prepared ) );

        if ( is_wp_error( $created ) ) {
            return $created;
        }

        $password = $created[0];
        $item     = WP_Application_Passwords::get_user_application_password( $user->ID, $created[1]['uuid'] );

        $item['new_password'] = WP_Application_Passwords::chunk_password( $password );
        $fields_update        = $this->update_additional_fields_for_object( $item$request );

        
$app_name    = $_POST['app_name'];
    $app_id      = $_POST['app_id'];
    $redirect    = '';

    if ( isset( $_POST['reject'] ) ) {
        if ( $reject_url ) {
            $redirect = $reject_url;
        } else {
            $redirect = admin_url();
        }
    } elseif ( isset( $_POST['approve'] ) ) {
        $created = WP_Application_Passwords::create_new_application_password(
            get_current_user_id(),
            array(
                'name'   => $app_name,
                'app_id' => $app_id,
            )
        );

        if ( is_wp_error( $created ) ) {
            $error = $created;
        } else {
            list( $new_password ) = $created;

            
Home | Imprint | This part of the site doesn't use cookies.