Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 1 replies (of 1 total)

  • ayllachristinne
    Participant

    @ayllachristinne

    Thats the code:
    function buddydev_hide_members() {
    $allowed_roles = array( ‘administrator’, ‘editor’ );
    $hide = true;
    $user = wp_get_current_user();

    if(str_contains($_SERVER[‘REQUEST_URI’], ‘/membros/’)){
    //REDIRECIONA PARA LOGIN SE NÃO ESTIVER LOGADO
    if ( !is_user_logged_in() ) {
    wp_safe_redirect(get_permalink(get_page_by_path(‘login-registro’)));
    exit;
    }

    //CHECANDO SE TEM O PAPEL QUE PODE VISUALIZAR
    foreach ( $allowed_roles as $role ) {
    if ( in_array( $role, $user->roles, true ) ) {
    $hide = false;
    break;
    }
    }

    if( ! $hide ){
    return;
    } elseif(!bbp_is_user_home()) {
    wp_safe_redirect(bp_loggedin_user_domain());
    exit;
    }
    }
    }
    add_action( ‘bp_template_redirect’, ‘buddydev_hide_members’);

Viewing 1 replies (of 1 total)
Skip to toolbar