Skip to:
Content
Pages
Categories
Search
Top
Bottom

Suspending user accounts


  • Jasper
    Participant

    @garyhamptonmcp

    We really need to suspend user accounts but not delete the data so we can reactivate them again at a later date.

    I have look looking for a solution to this for years and keep finding the same old forum posts with no solution.

    It seem so simple, just a nice button somewhere saying “suspend account” would be o so helpful…

    Any ideas please?

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)

  • danbp
    Moderator

    @danbp

    Consider this plugin:
    https://wordpress.org/plugins/disable-users/

    Works like a charm from within user profile admin.
    dashboard > users > username > modify and check Disable User Account


    Jasper
    Participant

    @garyhamptonmcp

    Thanks but this doesn’t work for what we need.

    If not so important that the user can’t sign in. What we need is for their BuddyPress profile to disappear when they get suspended and reappear when they get reactivated. We need to be able to put their profiles into sleep mode and not be visible by the public.


    danbp
    Moderator

    @danbp

    Afaik there is nothing out to do this.

    As start point, this snippet which let you hide a profile by user_id. Add it to bp-custom.php

    
    function bpfr_hide_user_profile() {
    global $bp; 
    // hide user_id 35
    if(bp_is_profile && $bp->displayed_user->id == 35 && $bp->loggedin_user->id != 35) :
       wp_redirect( home_url() );
       exit;
    endif;
    }
    add_action( 'wp', 'bpfr_hide_user_profile', 1 );

    Also, from here
    https://buddypress.org/support/topic/temporarily-blocking-a-user-while-keeping-their-datanetwork/
    https://wordpress.org/plugins/buddypress-verified/


    Jasper
    Participant

    @garyhamptonmcp

    Thanks, I must have done something wrong.

    I pasted in this code at the end of bp-custom.php and it crashed the site…


    danbp
    Moderator

    @danbp

    Do you use open and closing php tags ?

    A bp-custom.php file must contain one opening and one closing tag. And like any php file, without any blank line at begin and end of file. Here the one i’m using since years.

    <?php
    // Exit if accessed directly
    if ( ! defined( 'ABSPATH' ) ) exit;
    //////////////////////////////// - custom stuff start here - /////////////////////////////////
    
    function one() {
     ....
    }
    
    function whatever() {
    ...
    }
    
    //////// end of custom stuff /////////////////
    ?>

    Jasper
    Participant

    @garyhamptonmcp

    Thanks, I have this working now but the users are still visible. It does redirect to homepage if you try and click on them, but we need them to vanished once their account is suspended. and reappear again when they are reactivated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Suspending user accounts’ is closed to new replies.
Skip to toolbar