How To Only Allow Users To View Their Own Buddypress Profiles? [closed]

I solved this issue myself, it was quite easy and I’m surprised nobody else supplied an answer. Having said that, the solution is to add a few lines of code that check what the author ID is of the profile you’re viewing and compare it to the ID of the currently logged in user.

This code goes at the top of members/single/profile.php

<?php
    // Global $bp variable holds all of our info
    global $bp;

    // The user ID of the currently logged in user
    $current_user_id = (int) trim($bp->loggedin_user->id);

    // The author that we are currently viewing
    $author_id  = (int) trim($bp->displayed_user->id);

    if ($current_user_id !== $author_id)
    {
    // redirect to home page url
        wp_redirect(home_url());
        exit();
    }
?>