Skip to:
Content
Pages
Categories
Search
Top
Bottom

Search Results for 'private'

Viewing 25 results - 1,301 through 1,325 (of 3,460 total)
  • Author
    Search Results
  • #170716
    rtandoh
    Participant

    @henrywright-1, @shanebp

    Thank you very much. The code worked nicely, removing both the button and the functionality.

    rt.

    Hugo Ashmore
    Participant

    You probably ought to have migrated your bbPress group forums to the standalone plugin.

    #170638
    Squirrel
    Participant

    I just read the new Codex on child themes- so it should work with any theme- (answered my own question)

    Thank you for putting up with another newbie guys 🙂

    Best

    jaemaz
    Participant

    Bump.

    Anyone?

    #170635
    Squirrel
    Participant

    Thanks for the feedback

    I think I understand now- the profile page has activity on it so it’s not possible to do what that way, and it’s linked to the member page because that is showing profiles.

    I could hide things from members with template overrides as you suggest- but I’m not sure if it will work with my theme being a child theme of Twenty Thirteen. If I put the BuddyPress override template files in my child theme will it work?

    Thanks

    #170632
    shanebp
    Moderator

    So you want to block
    yoursite.com/members/
    and
    yoursite.com/activity/
    from users who aren’t admins or editors ?

    But allow everyone to view
    yoursite.com/members/my-profile?

    Then you might try putting a current_user_can conditional directly in the over-ride templates for those two pages.

    [there surely is a way to write a function to do this, but it escapes me at the moment]

    #170629
    Squirrel
    Participant

    Hi @shanebp and @henrywright-1

    Thanks for your help- I agree with Shanebp that his function does the same thing and is simpler, however I still have the same problem in that it stops access to the members PROFILE page.

    I think this must be a problem with BuddyPress though- maybe it’s a bug?

    Anyway thank you both for helping with the functions I think it will be handy for other things until I sort that problem out.

    #170628
    shanebp
    Moderator

    Perhaps a simpler way, given that she wants to check for both admin and editor, is to test against a cap that both admin and editor have.

    Something like: `function bp_my_restrict() {

    if ( !current_user_can(‘edit_posts’) ) {

    if ( bp_is_current_component(‘members’) || bp_is_current_component(‘activity’) ) {

    bp_core_redirect( home_url() );

    }
    }
    }
    add_action(‘wp’,’bp_my_restrict’);`

    #170624
    Henry
    Member

    Hi @mossyoak

    I’ve run a few tests and made some slight changes to that code. Try this

    function bp_my_restrict() {
       $user_id = bp_loggedin_user_id(); 
       $user = new WP_User( $user_id );
    	
          
    
             if ( ( $user->roles[0] != 'administrator' ) ) {
    		 
    		 if ( bp_is_current_component('members') || bp_is_current_component('activity')  ) {
                wp_redirect( home_url() );
    	    exit();
    	 }
          }
    }
    add_action('wp','bp_my_restrict');
    #170623
    Squirrel
    Participant

    Hi
    Thanks for your help again
    I tried your function

    function bp_my_restrict() {
       global $bp;
       $user_id = bp_loggedin_user_id(); 
       $user = new WP_User( $user_id );
    	
          if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
    
             if ( ( $user->roles[0] != 'administrator' ) ) {
                wp_redirect( $bp->loggedin_user->domain );
    	    exit();
    	 }
          }
    }
    add_action('wp','bp_my_restrict');

    But it gave a redirect loop error- I think it is because these conditionals are stopping the profile page being accessed for users lower than admin so trying to redirect to it is just looping.

    I changed the redirect to the home page which stopped the constant loop- but users who are not admin can still not access the profile page- these conditionals are stopping that which is a bit odd.

    // BuddyPress restrict activity and members page
    function bp_my_restrict() {
    global $bp;
    $user_id = bp_loggedin_user_id();
    $user = new WP_User( $user_id );
    
    if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
    if ( ( $user->roles[0] != 'administrator' ) ) {
    wp_redirect( home_url() ); exit;
    }
    }
    }
    add_action('wp','bp_my_restrict');

    Thank you for your help.

    #170618
    Henry
    Member

    Just read through your original question. The code snippet you’d want to add to your theme’s functions.php is something like this:

    function bp_my_restrict() {
       global $bp;
       $user_id = bp_loggedin_user_id(); 
       $user = new WP_User( $user_id );
    	
          if ( bp_is_current_component('members') || bp_is_current_component('activity') ) {
    
             if ( ( $user->roles[0] != 'administrator' ) ) {
                wp_redirect( $bp->loggedin_user->domain );
    	    exit();
    	 }
          }
    }
    add_action('wp','bp_my_restrict');
    #170617
    Henry
    Member

    Try this

    <?php
    
       $user_id = bp_loggedin_user_id(); 
       $user = new WP_User( $user_id );
       
       if ( $user->roles[0] != 'administrator' ) {
         // your code
       }
    
    ?>
    #170615
    Squirrel
    Participant

    There is still a problem though in that if I do this it stops any member who is not an admin level user accessing their profile page. Not sure why it should affect that- tried with just the activity conditional and it stops profile page access as well.

    elseif (bp_is_current_component( 'members' ) || bp_is_current_component( 'activity' )) :
    get_header('restrict');

    I’m using a header-restrict.php which redirects them with this redirect at the very top of it:

    <?php if(!current_user_can('delete_others_pages')) { wp_redirect( home_url() ); exit; } ?>

    Any ideas?

    #170614
    them8z
    Participant

    I disabled the plugin “simple chat” and it worked again!

    #170613
    Squirrel
    Participant

    Thanks for your help Henry- I tried the is_page conditional but it does not work with the BuddyPress Pages.

    So I tried bp_is_Page which worked, but was depecated.
    Then I tried
    bp_is_current_component( 'activity' ) || bp_is_current_component( 'members' )
    and they work for what I want.

    Thanks for your feedback it helped a lot 🙂

    Chris

    #170611
    Henry
    Member

    You could use the WordPress conditional is_page() to check if the user is on the activity or members page:

    if ( is_page('members') || is_page('activity') ) {
    
    } else {
    
    }

    Note: I’m assuming you haven’t changed the default slugs

    koomak
    Participant

    Is there anyone to help on this ?

    #170404
    funmi omoba
    Participant

    @shanebp,

    thanks for your reply I thought as much but I think it get wiped during the plugin update.

    Thanks for your input anyways.

    Best Regards

    #170403
    shanebp
    Moderator

    @funmi-omoba

    Open the plugin file, find the text, replace the text

    #170400
    funmi omoba
    Participant

    @shanebp,

    Thanks for your snippet which works great with standard buddypress message system but did not work if using BP Profile Message UX plugin, is there anyway to make it work please

    https://wordpress.org/plugins/bp-profile-message-ux/

    tahnks

    #170393
    Henry
    Member

    @shanebp – oops thanks for pointing that out. global $bp; can be removed

    #170392
    Henry
    Member

    @shanebp good point about using the bp_send_private_message_link approach. Although you would avoid double buttons by using a translation file.

    #170389
    shanebp
    Moderator

    @henrywright-1
    And how would you avoid double buttons due to this call in member-header.php?
    do_action( ‘bp_member_header_actions’ );


    @tayenewm

    Use the provided apply_filters:

    function tweak_button_label ( $args ) { 
    	$args[link_text] = 'Something'; 
    	return $args;
    }
    add_filter( 'bp_get_send_message_button_args', 'tweak_button_label', 1, 1 );
    #170388
    shanebp
    Moderator

    @henrywright-1
    Don’t include the global if you aren’t going to use it.

    #170387
    Henry
    Member

    actually you could make use of the bp_send_private_message_link function and do it like this:

    <a href="<?php bp_send_private_message_link() ?>" title="Private Message">Private Message</a>

    You can change the “Private Message” text to whatever you like. You’d just paste the code into your theme where ever you’d like the button to appear

Viewing 25 results - 1,301 through 1,325 (of 3,460 total)
Skip to toolbar