Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to hide CPT Links from profile view


  • ingohaeck
    Participant

    @ingohaeck

    For privacy issues I want to hide certain links on profile view.
    i use the snippet, mentioned here (see script below):
    one

    This works fine with BP related links, but I cannot hide links from CPT like rtMedia and the link of this:

    `function bp_postsonprofile() {
    add_action( ‘bp_template_content’, ‘profile_screen_posts_show’ );
    bp_core_load_template( apply_filters( ‘bp_core_template_plugin’, ‘members/single/plugins’ ) );
    }

    function profile_screen_posts_show() {

    $myposts = get_posts( array(
    ‘posts_per_page’ => -1,
    ‘author’ => bp_displayed_user_id(),
    ‘post_type’ => ‘post’
    ));

    if( ! empty($myposts) ) {

    echo ‘<ul>’;

    foreach($myposts as $post) {
    setup_postdata( $post );
    echo ‘<li><a href=”‘ . get_permalink($post->ID) . ‘”>’ . get_the_title($post->ID) . ‘</a></i>’;
    }

    echo ‘</ul>’;

    wp_reset_postdata();

    } else {

    echo ‘<div class=”info” id=”message”><p>’. bp_displayed_user_fullname() .’ hat keine Beiträge veröffentlicht.</p></div>’;
    }
    }

    add_action ( ‘profile_screen_posts_show’ );`

    function bpfr_hide_tabs() {
    global $bp;
    /**
    * class_exists() & bp_is_active are recommanded to avoid problems during updates
    * or when Component is deactivated
    */

    if( class_exists( ‘bbPress’ ) || bp_is_active ( ‘groups’ ) ) :

    /** here we fix the conditions.
    * Are we on a profile page ? | is user site admin ? | is user logged in ?
    */
    if ( bp_is_user() && !is_super_admin() && !is_user_logged_in() ) {

    /* and here we remove our stuff ! */
    bp_core_remove_nav_item( ‘activity’ );
    bp_core_remove_nav_item( ‘friends’ );
    bp_core_remove_nav_item( ‘groups’ );
    bp_core_remove_nav_item( ‘posts’ );
    bp_core_remove_nav_item( ‘forums’ );
    bp_core_remove_nav_item( ‘media’ );
    }
    endif;
    }
    add_action( ‘bp_setup_nav’, ‘bpfr_hide_tabs’, 15 );

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

  • leog371
    Participant

    @leog371

    Just to be sure of what your asking, Are you trying to hide these from everyone including the person who owns the profile?

    Just in case you dont want to hide them from the profile owner, you should know that any links that are edit, upload rtmedia links only display for the profile owner and no one else and most other things like this are hidden by default from users and friends anyways. Only a profile owner can upload and make changes to his profile or post activity on their profiles.

    Also, each member has privacy options in their profile settings. You can set defaults in the dashboard for this as well.

    If this is not the case, could you clarify what you hope to achieve?

    If you simply wish to remove links for everyone in your site including the profile owner, just use something like this in bp-custom.php file

    /* Example to Remove subnav tabs from Group Settings  https://codex.buddypress.org/developer/navigation-api/#examples*/ 	
    	function remove_group_manager_subnav_tabs() {   
        // site admin will see all tabs
        if ( ! bp_is_group() || ! ( bp_is_current_action( 'admin' ) && bp_action_variable( 0 ) ) || is_super_admin() ) {
            return;
        }
           // all subnav items are listed here.
           // comment those you want to show
            $hide_tabs = array(             
            //  'group-settings'    => 1,
            //    'delete-group'      => 1,
             //   'group-avatar'      => 1,
            //  'group-invites'     => 1,
             //   'manage-members'    => 1,
            //  'forum'             => 1,
            //  'group-cover-image' => 1
            );
                       
            $parent_nav_slug = bp_get_current_group_slug() . '_manage';
      
        //Remove the nav items
        foreach ( array_keys( $hide_tabs ) as $tab ) {
            bp_core_remove_subnav_item( $parent_nav_slug, $tab, 'groups' );
        }   
    }
    add_action( 'bp_actions', 'remove_group_manager_subnav_tabs' );

    ingohaeck
    Participant

    @ingohaeck

    Thank for your hint. To clarify my issue:
    I just want to remove the „media“- tab for logged out users, that rtmedia adds to the profile . The snippet, which I posted before does the job an removes all tabs, but not the media tab.

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.
Skip to toolbar