Skip to:
Content
Pages
Categories
Search
Top
Bottom

Removing Admin Link from Activity/Site


  • truelux
    Participant

    @truelux

    The name “Admin” appears when creating a group, post updated, etc in the activity stream and other areas. I noticed that there is a “bp_get_activity_user_link” filter.

    How can I create a function that “disables” the Admin link but creates link for all other users?

    function disable_admin_profile_link( $link ) {
    
       if( $link != bp_loggedin_user_domain() )
           $link = // custom url
    
       return $link; 
    }
    add_filter( 'bp_get_activity_user_link', 'disable_admin_profile_link', 15, 1 );

    vs something like this

    function _bp_core_get_user_domain($domain) {
    	$url = get_home_url();
    	$user_id = bp_get_member_user_id();
    	if (empty($user_id)) {
    		$user_id = bp_get_activity_user_id();
    	}
    	if (empty($user_id)) {
    		//$user_id = bp_displayed_user_id();
    	}
    	$user_info = get_userdata($user_id);
    	$link = $user_info->display_name;
    	$domain = '' . $url . '/profiles/' . $link . '';
    	return $domain;
        }
    add_filter('bp_core_get_user_domain', '_bp_core_get_user_domain', 10, 4);
    apply_filters( 'bp_get_activity_user_link', '_bp_core_get_user_domain', 15, 1);

    Not sure how to code it… If user is Admin, then link to homepage. If not, then link to their profile?

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

  • truelux
    Participant

    @truelux

    or do I create something off of this?

    function get_my_link ($string, $user_id) {
    	$url = get_home_url();
    	$user_info = get_userdata($user_id);
    	$name = $user_info->display_name;
    	$link = '<a href =' . $url . '/profiles/' . $name . '>' . $name . '</a>';
    	return $link;
    }
    add_filter ('bp_core_get_userlink', 'get_my_link', 10, 2);

    truelux
    Participant

    @truelux

    so this works on some of the activity but not all for some reason…

    /* Remove Admin Link */
    function remove_admin_alink ($string, $user_id) {
    	$url = get_home_url();
    	$user_info = get_userdata($user_id);
    	$aname = $user_info->user_login;
    	$name = $user_info->display_name;
    	if ($aname == "ADMINUSERNAME") {
    	$link = '<strong>Admin</strong>';
    	return $link;
    	} else {
    	return '<a href =' . $url . '/profiles/' . $name . '>' . $name . '</a>';
    	}
    }
    add_filter ('bp_core_get_userlink', 'remove_admin_alink', 10, 2);

    truelux
    Participant

    @truelux

    For some reason the “Admin” link still appears when adding a thread to a forum? Why would that be any different? Does it not use the bp_core_get_userlink filter?

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