Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'Hide Admin'

Viewing 25 results - 251 through 275 (of 915 total)
  • Author
    Search Results
  • #251113
    maelga
    Participant

    Hi, I’m using the below snippet from @danbp

    // deny access to admins profile. User is redirected to the homepage
    function bpfr_hide_admins_profile() {
    	global $bp; 
    	if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
    		wp_redirect( home_url() );
    	exit;
    	endif;
    }
    add_action( 'wp', 'bpfr_hide_admins_profile', 1 );

    When enabling WP_DEBUG, I get the following errors:

    • Use of undefined constant bp_is_profile – assumed ‘bp_is_profile’ in …/fonctions.php in line 291
    • Undefined property: stdClass::$id in …/fonctions.php in line 291

    Although the redirect works fine, is there any way to resolve these 2 errors?

    #250762
    @mcuk
    Participant

    This might help (change ID from 1 in the appropriate places to the ID of your administrator(s). ID’s found in your database ):

    https://buddypress.org/support/topic/hide-all-admins-from-all-buddypress-activities/

    #250727
    blogook
    Participant

    Hi,

    You can use the code from buddydev. You just have to change one single thing

    <?php
    //filter on pre_user_query
    add_action( 'pre_user_query', 'devb_exclude_loggedin_user', 201 );
    
    function devb_exclude_loggedin_user( $query ) {
        // code below we do not need
        //don't modify the query if the user is not logged in
        // if ( !is_user_logged_in() )
        //    return;
    
        //do not hide users inside the admin
        if ( is_admin() && !defined('DOING_AJAX') )
            return;
        $qv = $query->query_vars;
    
        global $wpdb;
        //hide little change at the end of the query.I changed it to user_id : 1
        // but userID can be anything. I chose 1 because that is my admin user_id
        $query->query_where .= $wpdb->prepare(" AND {$wpdb->users}.ID !=%d ", 1 );
    }
    ?>
    #250698
    jrb9406
    Participant

    Has anyone been successful at blocking buddypress pages until PMPRO email confirmation is complete? I seem to be getting nowhere with PMPRO folks.

    I am able to block /groups/, /members/, etc., but I cannot seem to block the sub-pages (e.g. /groups/group-name/). I took the PMPRO email confirmation code and modified it as follows. Any help is greatly appreciated!

    <?php
    /*
    Plugin Name: Paid Memberships Pro – Email Confirmation Add On
    Plugin URI: http://www.paidmembershipspro.com/addons/pmpro-email-confirmation/
    Description: Require email confirmation before certain levels are enabled for members.
    Version: .3
    Author: Stranger Studios
    Author URI: http://www.strangerstudios.com
    */
    /*
    Sample use case: You have a free level but want people to use a real email address when signing up.
    */

    /*
    [Deprecated] Set this array to the include the levels which should require email confirmation.

    global $pmpro_email_confirmation_levels;
    $pmpro_email_confirmation_levels = array(6);

    Use the checkbox on the edit levels page instead.
    */

    /*
    Add checkbox to edit level page to set if level requires email confirmation.
    */
    //show the checkbox on the edit level page
    function pmproec_pmpro_membership_level_after_other_settings()
    {
    $level_id = intval($_REQUEST[‘edit’]);
    if($level_id > 0)
    $email_confirmation = get_option(‘pmproec_email_confirmation_’ . $level_id);
    else
    $email_confirmation = false;
    ?>
    <h3 class=”topborder”>Email Confirmation</h3>
    <table>
    <tbody class=”form-table”>
    <tr>
    <th scope=”row” valign=”top”><label for=”email_confirmation”><?php _e(‘Email Confirmation:’, ‘pmpro’);?></label></th>
    <td>
    <input type=”checkbox” id=”email_confirmation” name=”email_confirmation” value=”1″ <?php checked($email_confirmation, 1);?> />
    <label for=”email_confirmation”><?php _e(‘Check this to require email validation for this level.’, ‘pmpro’);?></label>
    </td>
    </tr>
    </tbody>
    </table>
    <?php
    }
    add_action(‘pmpro_membership_level_after_other_settings’, ‘pmproec_pmpro_membership_level_after_other_settings’);

    //save email_confirmation setting when the level is saved/added
    function pmproec_pmpro_save_membership_level($level_id)
    {
    if(isset($_REQUEST[’email_confirmation’]))
    $email_confirmation = intval($_REQUEST[’email_confirmation’]);
    else
    $email_confirmation = 0;
    delete_option(‘pmproec_email_confirmation_’ . $level_id);
    add_option(‘pmproec_email_confirmation_’ . $level_id, $email_confirmation, ”, ‘no’);
    }
    add_action(“pmpro_save_membership_level”, “pmproec_pmpro_save_membership_level”);

    /*
    Functions
    */
    //Check if a level id requires an invite code or should generate one
    function pmproec_isEmailConfirmationLevel($level_id)
    {
    global $pmpro_email_confirmation_levels;

    //get value from options
    $email_confirmation = get_option(‘pmproec_email_confirmation_’ . $level_id, false);

    //check option and global var
    return (!empty($email_confirmation) || !empty($pmpro_email_confirmation_levels) && in_array($level_id, $pmpro_email_confirmation_levels));
    }

    //generate a key from a user id
    function pmproec_getValidationKey($user_id)
    {
    $key = md5($user_id . AUTH_KEY . $user_id);
    if(strlen($key) > 16)
    $key = substr($key, 0, 16);

    return $key;
    }

    /*
    Save validation key in user meta after checkout.
    */
    function pmproec_pmpro_after_checkout($user_id)
    {
    global $pmpro_level;

    if(pmproec_isEmailConfirmationLevel($pmpro_level->id))
    {
    //already validated?
    $oldkey = get_user_meta($user_id, “pmpro_email_confirmation_key”, true);
    if($oldkey != “validated”)
    {
    //nope? give them a key
    $key = pmproec_getValidationKey($user_id);
    update_user_meta($user_id, “pmpro_email_confirmation_key”, $key);
    }
    }
    }
    add_action(“pmpro_after_checkout”, “pmproec_pmpro_after_checkout”);

    /*
    If a user hasn’t validated yet and needs it, don’t give them access.
    */
    function pmproec_pmpro_has_membership_access_filter($hasaccess, $mypost, $myuser, $post_membership_levels)
    {
    //hide_buddy_press_pages()
    $uri = $_SERVER[‘REQUEST_URI’];

    //lock some things for members only
    $members_only = array(
    “/members-2/”, “/activity/”, “/groups-2/”, “/forums/”, “/welcome-back/”
    );
    //if they don’t have access, ignore this
    if(!$hasaccess)
    return $hasaccess;

    //if this isn’t locked by level, ignore this
    if(empty($post_membership_levels))
    return $hasaccess;

    //does this user have a level that requires confirmation?
    $user_membership_level = pmpro_getMembershipLevelForUser($myuser->ID);
    if(pmproec_isEmailConfirmationLevel($user_membership_level->id))
    {
    //if they still have a validation key, they haven’t clicked on the validation link yet
    $validation_key = get_user_meta($myuser->ID, “pmpro_email_confirmation_key”, true);

    if(!empty($validation_key) && $validation_key != “validated”)
    {
    $hasaccess = false;
    foreach($members_only as $check)
    {
    //make sure they are a member

    if(preg_match($check, $uri))
    {
    wp_redirect(“http://www.google.com&#8221;);
    exit;
    }
    }
    }
    }
    return $hasaccess;
    }
    add_filter(“pmpro_has_membership_access_filter”, “pmproec_pmpro_has_membership_access_filter”, 10, 4);

    /*
    Add validation lik to confirmation email.
    */
    function pmproec_pmpro_email_body($body, $email)
    {
    //must be a confirmation email and checkout template
    if(!empty($email->data[‘membership_id’]) && pmproec_isEmailConfirmationLevel($email->data[‘membership_id’]) && strpos($email->template, “checkout”) !== false)
    {
    //get user
    $user = get_user_by(“login”, $email->data[‘user_login’]);

    $validated = $user->pmpro_email_confirmation_key;
    $url = home_url(“?ui=” . $user->ID . “&validate=” . $validated);

    //need validation?
    if(empty($validated) || $validated != “validated”)
    {
    //use validation_link substitute?
    if(false === stripos($body, “!!validation_link!!”))
    {
    $body = “<p>IMPORTANT! You must follow this link to confirm your email address before your membership is fully activated:<br />” . $url . “</p><hr />” . $body;
    $body = str_replace(“Your membership account is now active.”, “”, $body);
    } else
    $body = str_ireplace(“!!validation_link!!”, $url, $body);
    }
    }

    return $body;
    }
    add_filter(“pmpro_email_body”, “pmproec_pmpro_email_body”, 10, 2);

    /*
    Process validation links.
    */
    function pmproec_init_validate()
    {
    if(!empty($_REQUEST[‘validate’]) && !empty($_REQUEST[‘ui’]))
    {
    $validate = $_REQUEST[‘validate’];
    $ui = $_REQUEST[‘ui’];
    $user = get_userdata($ui);
    if($validate == $user->pmpro_email_confirmation_key)
    {
    //validate!
    update_user_meta($user->ID, “pmpro_email_confirmation_key”, “validated”);

    do_action(‘pmproec_after_validate_user’, $user->ID, $validate);

    if(is_user_logged_in())
    wp_redirect(home_url());
    else
    wp_redirect(wp_login_url());

    exit;
    }
    }
    }
    add_action(“init”, “pmproec_init_validate”);

    /*
    Update confirmation page to mention validation email if needed.
    */
    function pmproec_pmpro_confirmation_message($message)
    {
    //must be an email confirmation level
    if(!empty($_REQUEST[‘level’]) && pmproec_isEmailConfirmationLevel(intval($_REQUEST[‘level’])))
    {
    global $current_user;
    if($current_user->pmpro_email_confirmation_key != “validated”)
    {
    $message = str_replace(“is now active”, “will be activated as soon as you confirm your email address. Important! You must click on the confirmation URL sent to ” . $current_user->user_email . ” before you gain full access to your membership“, $message);
    }
    }

    return $message;
    }
    add_filter(“pmpro_confirmation_message”, “pmproec_pmpro_confirmation_message”);

    /*
    Function to add links to the plugin row meta
    */
    function pmproec_plugin_row_meta($links, $file) {
    if(strpos($file, ‘pmpro-email-confirmation.php’) !== false)
    {
    $new_links = array(
    ‘ . __( ‘Support’, ‘pmpro’ ) . ‘‘,
    );
    $links = array_merge($links, $new_links);
    }
    return $links;
    }
    add_filter(‘plugin_row_meta’, ‘pmproec_plugin_row_meta’, 10, 2);

    /**
    * Add link to the user action links to validate a user
    *
    * Use the pmproec_validate_user_cap filter to change the capability required to see this.
    */
    function pmproec_user_row_actions($actions, $user) {
    $cap = apply_filters(‘pmproec_validate_user_cap’, ‘edit_users’);
    if(current_user_can($cap))
    {
    //check if they still have a validation key
    $validation_key = get_user_meta($user->ID, “pmpro_email_confirmation_key”, true);
    if(!empty($validation_key) && $validation_key != “validated”)
    {
    $url = admin_url(“users.php?pmproecvalidate=” . $user->ID);
    if(!empty($_REQUEST[‘s’]))
    $url .= “&s=” . esc_attr($_REQUEST[‘s’]);
    if(!empty($_REQUEST[‘paged’]))
    $url .= “&paged=” . intval($_REQUEST[‘paged’]);
    $url = wp_nonce_url($url, ‘pmproecvalidate_’ . $user->ID);
    $actions[] = ‘Validate User‘;
    }
    else
    $actions[] = ‘Validated’;
    }

    return $actions;
    }
    add_filter(‘user_row_actions’, ‘pmproec_user_row_actions’, 10, 2);
    add_filter(‘pmpro_memberslist_user_row_actions’, ‘pmproec_user_row_actions’, 10, 2);

    /**
    * Manually validate a user. Runs on admin init. Checks for pmproecvalidate and nonce and validates that user.
    *
    */
    function pmproec_validate_user()
    {
    if(!empty($_REQUEST[‘pmproecvalidate’]))
    {
    global $pmproec_msg, $pmproec_msgt;

    //get user id
    $user_id = intval($_REQUEST[‘pmproecvalidate’]);
    $user = get_userdata($user_id);

    //no user?
    if(empty($user))
    {
    //user not found error
    $pmproec_msg = ‘Could not reset sessions. User not found.’;
    $pmproec_msgt = ‘error’;
    }
    else
    {
    //check nonce
    check_admin_referer( ‘pmproecvalidate_’.$user_id);

    //check caps
    $cap = apply_filters(‘pmproec_validate_user_cap’, ‘edit_users’);
    if(!current_user_can($cap))
    {
    //show error message
    $pmproec_msg = ‘You do not have permission to validate users.’;
    $pmproec_msgt = ‘error’;
    }
    else
    {
    //validate!
    update_user_meta($user_id, “pmpro_email_confirmation_key”, “validated”);

    //show success message
    $pmproec_msg = $user->user_email . ‘ has been validated.’;
    $pmproec_msgt = ‘updated’;
    }
    }
    }
    }
    add_action(‘admin_init’, ‘pmproec_validate_user’);

    /**
    * Show any messages generated by PMPro Email Confirmations
    */
    function pmproec_admin_notices()
    {
    global $pmproec_msg, $pmproec_msgt;
    if(!empty($pmproec_msg))
    echo “<div class=\”$pmproec_msgt\”><p>$pmproec_msg</p></div>”;
    }
    add_action(‘admin_notices’, ‘pmproec_admin_notices’);

    RONO2
    Participant

    Hide Admin Bar Toolbar is what I used. I’m still trying to link my buddypress with my bbpress not going over well. LoL Hope this helps.

    #249961
    sokolum
    Participant

    Googled around, an older examples won’t work with the current version of BuddyPress 2.4.3. How to make sure that the activities of the Administrator isn’t recorded or not shown, sitewide / plugins / etc….

    Prefer to add this in: bp-custom.php

    Thank yo in advance.

    Code what i had found:

    
    <?php
    // Don’t record activity by the site admins or show them as recently active
    function my_admin_stealth_mode(){
    if ( is_site_admin() ) {
    global $bp;
    remove_action(‘wp_head’,’bp_core_record_activity’);
    delete_user_meta($bp->loggedin_user->id, ‘last_activity’);
    }
    ?>
    

    Here’s another code, this removes the activity of the currently logged in user itself from the page, this still works:
    But obviously it wont hide the administrator’s activity in the users perspective!

    
    <?php
    //filter on pre_user_query
    add_action( 'pre_user_query', 'devb_exclude_loggedin_user', 201 );
    
    function devb_exclude_loggedin_user( $query ) {
        //don't modify the query if the user is not logged in
        if ( !is_user_logged_in() )
            return;
        //do not hide users inside the admin
        if ( is_admin() && !defined('DOING_AJAX') )
            return;
        $qv = $query->query_vars;
    
        global $wpdb;
        //hide
        $query->query_where .= $wpdb->prepare(" AND {$wpdb->users}.ID !=%d ", get_current_user_id());
    }
    ?>
    
    #249827
    jino01
    Participant

    So there are two things I need to do:
    1) Hide admin mentionname somehow
    2) Members to have name and last name instead of the mentionname, maybe this will help with point 1?

    #249233
    Kookidooki
    Participant

    Thank you!

    It works fine, but when a (non-administrator) user is logged in, they cannot log out anymore because the logout button is missing which you can find in the “Howdy… [name][avatar][settings][logout button]” box at the upper right side. Also missing is the name of the user with his avatar, messages / notifications, etc. So this box is missing.

    So what I need is a script that hides the admin bar on the front end when you’re logged out, but is visible when you’re logged in.

    Any idea?

    ThanX!

    #248850
    Slava Abakumov
    Moderator

    All fields that are in the first Base fields groups will appear on registration page.
    So you can just move those fields to another fields group, that you can create on this page /wp-admin/users.php?page=bp-profile-setup using this link http://cosydale.com/wp-admin/users.php?page=bp-profile-setup&mode=add_group.

    Another option

    Find the ID of a field that you want to hide in admin area (when you edit the field it’s in the URL like this /wp-admin/users.php?page=bp-profile-setup&group_id=1&field_id=2&mode=edit_field = field_id=2 is what you need), make sure that this field is NOT required, then open style.css of your theme and add there something like this:
    #profile-details-section.register-section .editfield.field_2 {display:none}
    For reference: http://take.ms/lONUD

    #248412

    In reply to: Private Pages Glitch?

    fscbmwcca
    Participant

    I know the plugin doesn’t address my issue but keeps BuddyPress for members only and hide it from non-logged in users. Privacy is very important to our members. I will upload the members that are truly members from a csv file from a list that is provided for me and give the Contributor Role. What I meant by subscriber is the “Subscriber” Role (vs Contributor, Author, Editor, Administrator).
    I’m sorry I haven’t expressed myself well and now off topic. I was just trying to provide a solution for making pages private.

    #248133
    Max Zhubr
    Participant

    Hi there, All!

    How can I make a subnav with a static link in profile?
    I’ve got an Events+ plugin installed, and I’m trying to add a subnav link to the profile tab called “Events” with a static link, that should redirect to page /events/.

    Here is the code of the BP connected part of plugin:

    <?php
    /*
    Plugin Name: BuddyPress: My Events
    Description: Adds an Events tab to your user profiles.
    Plugin URI: http://premium.wpmudev.org/project/events-and-booking
    Version: 1.0
    AddonType: BuddyPress
    Author: WPMU DEV
    */
    
    /*
    Detail: Displays lists of user RSVPs on your users member pages.
    */
    
    class Eab_BuddyPress_MyEvents {
    
    	private $_data;
    
    	private function __construct () {
    		$this->_data = Eab_Options::get_instance();
    	}
    
    	public static function serve () {
    		$me = new Eab_BuddyPress_MyEvents;
    		$me->_add_hooks();
    	}
    
    	private function _add_hooks () {
    		add_action('admin_notices', array($this, 'show_nags'));
    		add_action('eab-settings-after_plugin_settings', array($this, 'show_settings'));
    		add_filter('eab-settings-before_save', array($this, 'save_settings'));
    
    		add_action('bp_init', array($this, 'add_bp_profile_entry'));
    	}
    
    	function show_nags () {
    		if (!defined('BP_VERSION')) {
    			echo '<div class="error"><p>' .
    				__("You'll need BuddyPress installed and activated for My Events add-on to work", Eab_EventsHub::TEXT_DOMAIN) .
    			'</p></div>';
    		}
    	}
    
    	private function _check_permissions () {
    		$post_type = get_post_type_object(Eab_EventModel::POST_TYPE);
    		return current_user_can($post_type->cap->edit_posts);
    	}
    
    	function add_bp_profile_entry () {
    		global $bp;
    		bp_core_new_nav_item(array(
    			'name' => __('Events', Eab_EventsHub::TEXT_DOMAIN),
    			'slug' => 'my-events',
    			'show_for_displayed_user' => true,
    			'default_subnav_slug' => ($this->_check_permissions() ? 'organized' : 'attending'),
    			'screen_function' => '__return_false',
    		));
    		if ($this->_check_permissions()) {
    			bp_core_new_subnav_item(array(
    				'name' => __('Organized', Eab_EventsHub::TEXT_DOMAIN),
    				'slug' => 'organized',
    				'parent_url' => $bp->displayed_user->domain . 'my-events' . '/',
    				'parent_slug' => 'my-events',
    				'screen_function' => array($this, 'bind_bp_organized_page'),
    			));
    		}
    		bp_core_new_subnav_item(array(
    			'name' => __('Attending', Eab_EventsHub::TEXT_DOMAIN),
    			'slug' => 'attending',
    			'parent_url' => $bp->displayed_user->domain . 'my-events' . '/',
    			'parent_slug' => 'my-events',
    			'screen_function' => array($this, 'bind_bp_attending_page'),
    		));
    		bp_core_new_subnav_item(array(
    			'name' => __('Maybe', Eab_EventsHub::TEXT_DOMAIN),
    			'slug' => 'mabe',
    			'parent_url' => $bp->displayed_user->domain . 'my-events' . '/',
    			'parent_slug' => 'my-events',
    			'screen_function' => array($this, 'bind_bp_maybe_page'),
    		));
    		bp_core_new_subnav_item(array(
    			'name' => __('Not Attending', Eab_EventsHub::TEXT_DOMAIN),
    			'slug' => 'not-attending',
    			'parent_url' => $bp->displayed_user->domain . 'my-events' . '/',
    			'parent_slug' => 'my-events',
    			'screen_function' => array($this, 'bind_bp_not_attending_page'),
    		));
    		do_action('eab-events-my_events-set_up_navigation');
    	}
    
    	function bind_bp_organized_page () {
    		add_action('bp_template_title', array($this, 'show_organized_title'));
    		add_action('bp_template_content', array($this, 'show_organized_body'));
    		add_action('bp_head', array($this, 'enqueue_dependencies'));
    		bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
    	}
    	function bind_bp_attending_page () {
    		add_action('bp_template_title', array($this, 'show_attending_title'));
    		add_action('bp_template_content', array($this, 'show_attending_body'));
    		add_action('bp_head', array($this, 'enqueue_dependencies'));
    		bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
    	}
    	function bind_bp_maybe_page () {
    		add_action('bp_template_title', array($this, 'show_maybe_title'));
    		add_action('bp_template_content', array($this, 'show_maybe_body'));
    		add_action('bp_head', array($this, 'enqueue_dependencies'));
    		bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
    	}
    	function bind_bp_not_attending_page () {
    		add_action('bp_template_title', array($this, 'show_not_attending_title'));
    		add_action('bp_template_content', array($this, 'show_not_attending_body'));
    		add_action('bp_head', array($this, 'enqueue_dependencies'));
    		bp_core_load_template(apply_filters('bp_core_template_plugin', 'members/single/plugins'));
    	}
    
    	function enqueue_dependencies () {
    		global $bp;
    		if ('my-events' != $bp->current_component) return false;
    		wp_enqueue_style('eab-bp-my_events', plugins_url('events-and-bookings/css/eab-buddypress-my_events.css'));
    	}
    
    	function show_organized_title () {
    		echo __('Organized Events', Eab_EventsHub::TEXT_DOMAIN);
    	}
    	function show_attending_title () {
    		echo __('Attending Events', Eab_EventsHub::TEXT_DOMAIN);
    	}
    	function show_maybe_title () {
    		echo __('Maybe attending Events', Eab_EventsHub::TEXT_DOMAIN);
    	}
    	function show_not_attending_title () {
    		echo __('Not attending Events', Eab_EventsHub::TEXT_DOMAIN);
    	}
    
    	function show_organized_body () {
    		global $bp;
    		echo '<div id="eab-bp-my_events-wrapper">';
    		echo '<div class="eab-bp-my_events eab-bp-organized">' .
    			Eab_Template::get_user_organized_events($bp->displayed_user->id) .
    		'</div>';
    		echo '</div>';
    	}
    	function show_attending_body () {
    		global $bp;
    		$premium = $this->_data->get_option('bp-my_events-premium_events');
    		if (!empty($premium)) {
    			if ('nag' == $premium) add_filter('eab-event-user_events-before_meta', array($this, 'premium_event_rsvp'), 10, 3);
    			if ('hide' == $premium) add_filter('eab-event-user_events-exclude_event', array($this, 'exclude_premium_event_rsvp'), 10, 2);
    		}
    		echo '<div id="eab-bp-my_events-wrapper">';
    		echo '<div class="eab-bp-my_events eab-bp-rsvp_yes">' .
    			Eab_Template::get_user_events(Eab_EventModel::BOOKING_YES, $bp->displayed_user->id) .
    		'</div>';
    		echo '</div>';
    	}
    	function show_maybe_body () {
    		global $bp;
    		echo '<div id="eab-bp-my_events-wrapper">';
    		echo '<div class="eab-bp-my_events eab-bp-rsvp_maybe">' .
    			Eab_Template::get_user_events(Eab_EventModel::BOOKING_MAYBE, $bp->displayed_user->id) .
    		'</div>';
    		echo '</div>';
    	}
    	function show_not_attending_body () {
    		global $bp;
    		echo '<div id="eab-bp-my_events-wrapper">';
    		echo '<div class="eab-bp-my_events eab-bp-rsvp_no">' .
    			Eab_Template::get_user_events(Eab_EventModel::BOOKING_NO, $bp->displayed_user->id) .
    		'</div>';
    		echo '</div>';
    	}
    
    	function premium_event_rsvp ($content, $event, $status) {
    		if (!$event->is_premium()) return $content;
    
    		global $bp;
    		$user_id = $bp->displayed_user->id;
    		if (Eab_EventModel::BOOKING_YES != $status) return $content;
    		if ($event->user_paid($user_id)) return $content;
    
    		$content .= '<div class="eab-premium_event-unpaid_notice"><b>' . __('Event not paid', Eab_EventsHub::TEXT_DOMAIN) . '</b></div>';
    
    		return $content;
    	}
    
    	function exclude_premium_event_rsvp ($exclude, $event) {
    		if ($exclude) return $exclude;
    
    		global $bp;
    		$user_id = $bp->displayed_user->id;
    
    		if (!$event->is_premium()) return false;
    		return !$event->user_paid($user_id);
    	}
    
    	function show_settings () {
    		$tips = new WpmuDev_HelpTooltips();
    		$tips->set_icon_url(plugins_url('events-and-bookings/img/information.png'));
    		$premium = $this->_data->get_option('bp-my_events-premium_events');
    		$options = array(
    			'' => __('Do nothing special', Eab_EventsHub::TEXT_DOMAIN),
    			'hide' => __('Hide', Eab_EventsHub::TEXT_DOMAIN),
    			'nag' => __('Show nag notice', Eab_EventsHub::TEXT_DOMAIN),
    		);
    ?>
    <div id="eab-settings-my_events" class="eab-metabox postbox">
    	<h3 class="eab-hndle"><?php _e('My Events settings', Eab_EventsHub::TEXT_DOMAIN); ?></h3>
    	<div class="eab-inside">
    		<div class="eab-settings-settings_item" style="line-height:1.8em">
    	    	<label for="eab_event-bp-my_events-premium_events"><?php _e('Non-paid premium events with positive RSPVs', Eab_EventsHub::TEXT_DOMAIN); ?>:</label>
    	    	<?php foreach ($options as $value => $label) { ?>
    	    		<br />
    				<input type="radio" id="eab_event-bp-my_events-premium_events-<?php echo esc_attr($value); ?>" name="event_default[bp-my_events-premium_events]" value="<?php echo esc_attr($value); ?>" <?php checked($value, $premium); ?> />
    	    		<label for="eab_event-bp-my_events-premium_events-<?php echo esc_attr($value); ?>"><?php echo esc_html($label) ?></label>
    	    	<?php } ?>
    			<span><?php echo $tips->add_tip(__('How to deal with non-paid premium events on user events list display.', Eab_EventsHub::TEXT_DOMAIN)); ?></span>
    	    </div>
    	</div>
    </div>
    <?php
    	}
    
    	function save_settings ($options) {
    		$options['bp-my_events-premium_events'] = $_POST['event_default']['bp-my_events-premium_events'];
    		return $options;
    	}
    }
    
    Eab_BuddyPress_MyEvents::serve();
    
    class Eab_MyEvents_Shortcodes extends Eab_Codec {
    
    	protected $_shortcodes = array(
    		'my_events' => 'eab_my_events',
    	);
    
    	public static function serve () {
    		$me = new Eab_MyEvents_Shortcodes;
    		$me->_register();
    	}
    
    	function process_my_events_shortcode ($args=array(), $content=false) {
    		$args = $this->_preparse_arguments($args, array(
    		// Query arguments
    			'user' => false, // User ID or keyword
    		// Appearance arguments
    			'class' => 'eab-my_events',
    			'show_titles' => 'yes',
    			'sections' => 'organized,yes,maybe,no',
    		));
    
    		if (is_numeric($args['user'])) {
    			$args['user'] = $this->_arg_to_int($args['user']);
    		} else {
    			if ('current' == trim($args['user'])) {
    				$user = wp_get_current_user();
    				$args['user'] = $user->ID;
    			} else {
    				$args['user'] = false;
    			}
    		}
    		if (empty($args['user'])) return $content;
    
    		$args['sections'] = $this->_arg_to_str_list($args['sections']);
    		$args['show_titles'] = $this->_arg_to_bool($args['show_titles']);
    
    		$output = '';
    
    		// Check if the user can organize events
    		$post_type = get_post_type_object(Eab_EventModel::POST_TYPE);
    		if (in_array('organized', $args['sections']) && user_can($args['user'], $post_type->cap->edit_posts)) {
    			$output .= '<div class="' . $args['class'] . ' eab-bp-organized">' .
    				($args['show_titles'] ? '<h4>' . __('Organized Events', Eab_EventsHub::TEXT_DOMAIN) . '</h4>' : '') .
    				Eab_Template::get_user_organized_events($args['user']) .
    			'</div>';
    		}
    
    		if (in_array('yes', $args['sections'])) {
    			$output .= '<div class="' . $args['class'] . ' eab-bp-rsvp_yes">' .
    				($args['show_titles'] ? '<h4>' . __('Attending Events', Eab_EventsHub::TEXT_DOMAIN) . '</h4>' : '') .
    				Eab_Template::get_user_events(Eab_EventModel::BOOKING_YES, $args['user']) .
    			'</div>';
    		}
    
    		if (in_array('maybe', $args['sections'])) {
    			$output .= '<div class="' . $args['class'] . ' eab-bp-rsvp_maybe">' .
    				($args['show_titles'] ? '<h4>' . __('Maybe attending Events', Eab_EventsHub::TEXT_DOMAIN) . '</h4>' : '') .
    				Eab_Template::get_user_events(Eab_EventModel::BOOKING_MAYBE, $args['user']) .
    			'</div>';
    		}
    
    		if (in_array('no', $args['sections'])) {
    			$output .= '<div class="' . $args['class'] . ' eab-bp-rsvp_no">' .
    				($args['show_titles'] ? '<h4>' . __('Not attending Events', Eab_EventsHub::TEXT_DOMAIN) . '</h4>' : '') .
    				Eab_Template::get_user_events(Eab_EventModel::BOOKING_NO, $args['user']) .
    			'</div>';
    		}
    
    		$output = $output ? $output : $content;
    
    		return $output;
    	}
    
    	public function add_my_events_shortcode_help ($help) {
    		$help[] = array(
    			'title' => __('My Events archives', Eab_EventsHub::TEXT_DOMAIN),
    			'tag' => 'eab_my_events',
    			'arguments' => array(
    				'user' => array('help' => __('User ID or keyword "current".', Eab_EventsHub::TEXT_DOMAIN), 'type' => 'string:or_integer'),
    				'class' => array('help' => __('Apply this CSS class', Eab_EventsHub::TEXT_DOMAIN), 'type' => 'string'),
    				'show_titles' => array('help' => __('Show section titles', Eab_EventsHub::TEXT_DOMAIN), 'type' => 'boolean'),
    				'sections' => array('help' => __('Show these sections. Possible values: "organized", "yes", "maybe", "no".', Eab_EventsHub::TEXT_DOMAIN), 'type' => 'string:list'),
    			),
    		);
    		return $help;
    	}
    }
    
    Eab_MyEvents_Shortcodes::serve();

    Thanks in advance!

    #247818
    buckyb
    Participant

    Thank you for replying, I tried to figure it out on my own, but I cant get it to work. I changed some of the lines, and included what you have, but it breaks the site. (still learning, please bear with me)

    function bpfr_hide_profile_field_group( $retval ) {
    $displayed_user_level = some_s2_function( bp_displayed_user_id() ); 
    if( is_super_admin() && $displayed_user_level == 'access_s2member_level1' )  {
    // exlude groups, separated by comma
    		$retval['exclude_groups'] = '6,5';          		
    	} 
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
    #247706
    shanebp
    Moderator

    The above is wrong – unless you are using the bp-default theme – not recommended.

    ‘Hide’ the Create a Group link by turning it off in Groups Settings > Group Creation
    .../wp-admin/admin.php?page=bp-settings

    sincewelastspoke
    Participant

    How do I hide my ‘Members’ page from all except Admin?

    #247432

    In reply to: hide bp toolbar

    dwsowash
    Participant

    This in you function php hides it from everyone but admins

    //Removes BuddyBar from non-admins only
    function splen_remove_admin_bar() {
    	if( !is_super_admin() ) 
    		add_filter( 'show_admin_bar', '__return_false' );
    }
    add_action('wp', 'splen_remove_admin_bar');
    

    Is that what you mean?

    buckyb
    Participant

    Hello,

    I have 2 s2member levels, and quite a bit of groups for each level, it’s getting confusing for the admin when editing. I’d like to hide some of the groups from the admin in the EDIT section if the user is in a specific level.

    I found this below and tweaked it for s2member, but alas it doesn’t work LOL, if anyone can help, would greatly appreciate it!!

    // Hide profile group to admin based on Levels
    function bpfr_hide_profile_field_group( $retval ) {
    	if( current_user_is(administrator) && current_user_can("access_s2member_level1") ) {
               // exlude groups, separated by comma
    		$retval['exclude_groups'] = '6,5';          		
    	} 
    	return $retval;	
    }
    add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );
    #246529
    danbp
    Participant

    Try

    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' ) ) :
    
    	if ( bp_is_user() && !is_super_admin() && !bp_is_my_profile() ) {
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'forums' );
    		bp_core_remove_subnav_item( 'activity', 'groups' );
    	}
    	endif;
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    #246528
    danbp
    Participant

    @paragbhagwat,

    try this:

    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' ) ) :
    
    	if ( bp_is_user() && !is_super_admin() && !bp_is_my_profile() ) {
    		bp_core_remove_nav_item( 'groups' );
    		bp_core_remove_nav_item( 'forums' );
    		bp_core_remove_subnav_item( 'activity', 'groups' );
    	}
    	endif;
    }
    add_action( 'bp_setup_nav', 'bpfr_hide_tabs', 15 );
    paragbhagwat
    Participant

    Hello,

    I am trying to hide the groups and forums tabs from all users except admin and the logged in users own profile. The slugs i want to hide are
    /members/betauser/forums/
    /members/betauser/groups/

    I am writing the code as shown below to get this to work but it seems i am always using the logged in user to create the /members/xxx slug where as i may need the user that was clicked.. Any ideas on what i am doing wrong here?

    
    add_action( 'bp_actions', 'RECN_CUSTOM_MEMBER_REMOVE_SUBNAV' );
    function RECN_CUSTOM_MEMBER_REMOVE_SUBNAV()
    {
        bp_core_add_message(' ok i222n the mnethod','error');
        if(is_super_admin() || bp_is_my_profile())
        {
            bp_core_add_message(' ok in the mnethod 1','error');
            return;
        }
    
        $hide_tabs = array(
            'forums'=>1,
            'groups'=>1,
        );
    
        $username = bp_core_get_username( bp_loggedin_user_id() );
    
        //$parent_nav_slug =bp_get_members_root_slug() . '/' . $username;
        $parent_nav_slug =bp_get_members_root_slug();
    
        bp_core_add_message(' ok in the mnethod 2'.$parent_nav_slug,'error');
        foreach ( array_keys( $hide_tabs ) as $tab ) {
            bp_core_remove_subnav_item( $parent_nav_slug, $tab );
        }
    
        if ( ! empty( $hide_tabs[ bp_action_variable( 0 ) ] ) ) {
            bp_core_add_message( 'Sorry buddy, but this part is restricted to super admins!', 'error' );
            bp_core_redirect( bp_get_group_permalink( groups_get_current_group() ) );
        }
    
    }
    

    Thanks,
    Parag Bhagwat

    buckyb
    Participant

    Hello,

    Was wondering how to hide a custom tab I created and show it only to the account owner and the admin only.

    This is my custom tab

    function profile_new_nav_item() {
    global $bp;
    $post_count = count_user_posts_by_type( $bp->displayed_user->id );

    bp_core_new_nav_item(
    array(
    ‘name’ => ‘My Page’,
    ‘slug’ => ‘my-page’,
    ‘default_subnav_slug’ => ‘my-page’,
    ‘position’ => 30,
    ‘show_for_displayed_user’ => true,
    ‘screen_function’ => ‘view_manage_tab_main’,
    ‘parent_url’ => $bp->loggedin_user->domain . $bp->slug . ‘/’,
    ‘parent_slug’ => $bp->slug
    )
    );
    }

    function view_manage_tab_main() {
    add_action( ‘bp_template_content’, ‘bp_template_content_main_function’ );
    bp_get_template_part( ‘members/single/plugins’ );
    }

    function bp_template_content_main_function() {
    if ( ! is_user_logged_in() && !bp_is_my_profile()) {
    wp_login_form( array( ‘echo’ => true ) );

    } else {
    //Add content
    include(locate_template(‘members/single/profile/my-page.php’));

    }
    }
    add_action( ‘bp_setup_nav’, ‘profile_new_nav_item’, 50 );

    Thanks!

    #246094
    splufford
    Participant

    Hi, struggling to get any of the the code in post #190874 to work. I have created a bp-custom.php file which I have uploaded to the root of the buddpress folder and my code looks like this:

    <?php
    // deny access to admins profile. User is redirected to the homepage
    function bpfr_hide_admins_profile() {
    	global $bp; 
    	if(bp_is_profile && $bp->displayed_user->id == 1 && $bp->loggedin_user->id != 1) :
    		wp_redirect( home_url() );
    	exit;
    	endif;
    }
    add_action( 'wp', 'bpfr_hide_admins_profile', 1 );
    
    // Remove admin from the member directory
    function bpdev_exclude_users($qs=false,$object=false){
        
        $excluded_user='1'; // Id's to remove, separated by comma
    	
        if($object != 'members' && $object != 'friends')// hide admin to members & friends 
        return $qs;
    	
        $args=wp_parse_args($qs);
    
        if(!empty($args['user_id']))
        return $qs;	
    	
        if(!empty($args['exclude']))
    		$args['exclude'] = $args['exclude'].','.$excluded_user;
        else
    		$args['exclude'] = $excluded_user;
    	
        $qs = build_query($args);
    
        return $qs;
    	
    }
    add_action('bp_ajax_querystring','bpdev_exclude_users',20,2);
    
    // once admin is removed, we must recount the members !
    function bpfr_hide_get_total_filter($count){
        return $count-1;
    }
    add_filter('bp_get_total_member_count','bpfr_hide_get_total_filter');
    // hide admin's activities from all activity feeds
    function bpfr_hide_admin_activity( $a, $activities ) {	
    	
    	// ... but allow admin to see his activities!
    	if ( is_site_admin() )	
    		return $activities;	
    	
    	foreach ( $activities->activities as $key => $activity ) {	
    		// ID's to exclude, separated by commas. ID 1 is always the superadmin
    		if ( $activity->user_id == 1  ) {			
    			
    			unset( $activities->activities[$key] );			
    			
    			$activities->activity_count = $activities->activity_count-1;			
    			$activities->total_activity_count = $activities->total_activity_count-1;			
    					$activities->pag_num = $activities->pag_num -1;				
    		}		
    	}		
    	// Renumber the array keys to account for missing items 	
    	$activities_new = array_values( $activities->activities );		
    	$activities->activities = $activities_new;	
    	
    	return $activities;
    	
    }
    add_action( 'bp_has_activities', 'bpfr_hide_admin_activity', 10, 2 );
    ?>

    Not sure what I am doing wrong. All help gratefully received! Thanks

    #246041
    mrjarbenne
    Participant

    You could try this: https://github.com/r-a-y/bp-hide-user

    I don’t use it to hide admin members, but to hide users who are members of a subsite on multisite who I don’t want seen in the main activity feed. If it doesn’t do exactly what you want, I’m sure it’s a great start.

    #246031
    pnet
    Participant

    I have been searching for the same, hide admins from GROUP members list.
    It seems all the forums point to https://buddypress.org/support/topic/hide-admin-from-members-and-activity/

    Which the second block of code does not work, for me anyway, breaks my site.

    So how do I hide the admins from GROUP members list, not all members list, I have those hidden.

    #245646
    Venutius
    Moderator
    #245361
    Henry Wright
    Moderator

    In post #190874 on the topic you’ve linked to, snippet 2 has the line:

    $excluded_user='1'; // Id's to remove, separated by comma

    You can just add more user IDs like this and those IDs will be excluded from the loop:

    $excluded_user='1,34,56,201'; // Id's to remove, separated by comma

Viewing 25 results - 251 through 275 (of 915 total)
Skip to toolbar