Disabling avatar file uploads in the GiveWP Donor Dashboard

Dec 06, 2022 #givewp

The Donor Dashboard is a feature of GiveWP with which donors can view their donation history, download donation receipts, and manage recurring donations. It also features an editable profile, including a donor avatar.

The avatar feature includes a file upload field because WordPress user accounts do not natively support custom avatars. However, sites with active security threats may opt to disable file uploads on their site. The GiveWP Donor Dashboard avatar upload is easily disabled using the following snippet.

add_action('give_embed_head', function() {
    echo '
        <style>
            /* Hide the avatar and upload form.  */
            .give-donor-dashboard-avatar-control,
            .give-donor-dashboard-donor-info__avatar {
                display: none !important;
            }
            .give-donor-dashboard-donor-info {
                display: block !important;
            }
        </style>
    ';
});

add_filter('rest_endpoints', function($endpoints) {
    // Remove the Donor Dashboard avatar upload route.
    unset($endpoints['/give-api/v2/donor-dashboard/avatar']);
    return $endpoints;
});
By Kyle B. Johnson
Founding Member

Kyle Johnson is a contributor to WordPress core, WP-CLI, and Gutenberg. He speaks at WordCamps and Open Source conferences. As a collector of hobbies he is also a musician, furniture maker, amateur lock pick, avid reader, and wannabe book author.

Site Builders Guild - Tools and community for people who build websites.