Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 25 replies - 1 through 25 (of 57 total)

  • livingflame
    Participant

    @livingflame

    Currently PMPro has no official relationship with BuddyPress.

    The relationship depends on the Theme.

    Themes like SweetDate have options for PMPro.


    livingflame
    Participant

    @livingflame

    Okey, here is the correct code, thanks to @brajesh

    // Adding message button in members directory 
    
    function filter_message_button_link( $link ) {
    
        $link =  wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r='. bp_core_get_username( bp_get_member_user_id() ) );
    
    return $link;
    
    }
    
    function display_private_message_button() {
    
        if( is_user_logged_in() && bp_get_member_user_id() != bp_loggedin_user_id() ) {
    
            //bp_send_message_button();
            ?>
            <div id="send-private-message" class="generic-button">
    
                <div class="private-message-button generic-button" ><a href="<?php echo filter_message_button_link(); ?>" class="button small secondary radius" rel="add"><i class="icon-envelope"></i></a></div>
            </div>
    
            <?php
            add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 );
            }
    }
    add_action( 'bp_directory_members_item_last', 'display_private_message_button',9999 );
    
    

    livingflame
    Participant

    @livingflame


    livingflame
    Participant

    @livingflame

    @shanebp

    Other option can be: If the button is visible, and you are not a member, redirect to Register Page after you click on this.


    livingflame
    Participant

    @livingflame

    Functions.php
    Only works with Newest Registered.

    // Force Strong Username
    function strong_username() {
     global $bp;
    
     if ( !empty( $_POST['signup_username'] ) )
       if ( !valid_username( $_POST['signup_username'] ) ){
        $bp->signup->errors['signup_username'] = __( 'Your username is too weak or short. Please, use uppercase, lowercase and numbers.', 'bp-strong-username-password', 'buddypress' );
       }
     }
     add_action( 'bp_signup_validate', 'strong_username');
    
     function valid_username($candidate) {
       $r1='/[A-Z]/';  //Uppercase 
       $r2='/[a-z]/';  //lowercase
       $r3='/[0-9]/';  //numbers
    
       if(preg_match_all($r1,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r2,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r3,$candidate, $o)<1) return FALSE;
       if(strlen($candidate)<8) return FALSE;
    
       return TRUE;
    }
    // Force Strong Password
    function strong_validation() {
     global $bp;
    
     if ( !empty( $_POST['signup_password'] ) )
       if ( !valid_pass( $_POST['signup_password'] ) ){
        $bp->signup->errors['signup_password'] = __( 'Your password is too weak or short. Please, use uppercase, lowercase, numbers and special characters.', 'bp-strong-username-password', 'buddypress' );
       }
     }
     add_action( 'bp_signup_validate', 'strong_validation');
    
     function valid_pass($candidate) {
       $r1='/[A-Z]/';  //Uppercase
       $r2='/[a-z]/';  //lowercase
       $r3='/[!@#$%^&*()-_=+{};:,?<.>]/';  // whatever you mean by special char
       $r4='/[0-9]/';  //numbers
    
       if(preg_match_all($r1,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r2,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r3,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r4,$candidate, $o)<1) return FALSE;
       if(strlen($candidate)<10) return FALSE;
    
       return TRUE;
    }

    livingflame
    Participant

    @livingflame

    I understand you now.

    You can try this: Link


    livingflame
    Participant

    @livingflame

    Okey @coach-afrane, you want something like this: Thrive link


    livingflame
    Participant

    @livingflame

    @coach-afrane

    Functions.php

    // Limit the Access To WordPress Dashboard. Only Admin 
    add_action( 'init', 'blockusers_init' );
    function blockusers_init() {
     if ( is_admin() && !current_user_can( 'administrator' ) && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
     wp_redirect( home_url() );
     exit;
     }
    }
    // Limit the Access To WordPress Dashboard. Only Admin and Editor 
    add_action( 'init', 'blockusers_init' );
    function blockusers_init() {
     if ( is_admin() && !current_user_can( 'administrator' ) && !current_user_can( 'editor' ) && !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
     wp_redirect( home_url() );
     exit;
     }
    }
    // BP Redirect To Profile 
    function redirect_to_profile( $redirect_to_calculated, $redirect_url_specified, $user ) {
    if ( ! $user || is_wp_error( $user ) ) {
    		return $redirect_to_calculated;
    	}
    //If the redirect is not specified, assume it to be dashboard
    	if ( empty( $redirect_to_calculated ) ) {
    		$redirect_to_calculated = admin_url();
    	}
    // if the user is not site admin, redirect to his/her profile
    	if ( ! is_super_admin( $user->ID ) ) {
    		return bp_core_get_user_domain( $user->ID );
    	} else {
    		//if site admin or not logged in, do not do anything much
    		return $redirect_to_calculated;
    	}
    }
    add_filter( 'login_redirect', 'redirect_to_profile', 100, 3 );
    // Exclude Admins from Directories and BP Widgets 
    add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
    
    function buddydev_exclude_users( $args ) {
    	//do not exclude in admin
    	if( is_admin() && ! defined( 'DOING_AJAX' ) ) {
    		return $args;
    	}
    	
    	$excluded = isset( $args['exclude'] )? $args['exclude'] : array();
    
    	if( !is_array( $excluded ) ) {
    		$excluded = explode(',', $excluded );
    	}
    	
    	$user_ids = array( 1 ); //user ids
    	
    	
    	$excluded = array_merge( $excluded, $user_ids );
    	
    	$args['exclude'] = $excluded;
    	
    	return $args;
    }

    livingflame
    Participant

    @livingflame

    Help me with the code.
    I need the Message button visible only to logged in users (Just like the Add Friend button works).

    Check the code, please.

    // Adding message button in members loop
    
    function filter_message_button_link( $link ) {
    
        $link =  wp_nonce_url( bp_loggedin_user_domain() . bp_get_messages_slug() . '/compose/?r='. bp_core_get_username( bp_get_member_user_id() ) );
    
    return $link;
    
    }
    
    function display_private_message_button() {
    
        if( bp_get_member_user_id() != bp_loggedin_user_id() ) {
    
            //bp_send_message_button();
            ?>
            <div id="send-private-message" class="generic-button">
    
                <div class="private-message-button generic-button" ><a href="<?php echo filter_message_button_link(); ?>" class="button small secondary radius" rel="add"><i class="icon-envelope"></i></a></div>
            </div>
    
            <?php
            add_filter('bp_get_send_private_message_link', 'filter_message_button_link', 1, 1 );
            }
    }
    add_action( 'bp_directory_members_item_last', 'display_private_message_button',9999 );
    
    


    @modemlooper


    @sbrajesh


    @mercime


    livingflame
    Participant

    @livingflame

    Try with this:

    function tubs_sanitize_user($username, $raw_username, $strict) {
        $new_username = strip_tags($raw_username);
        // Kill octets
        $new_username = preg_replace('|%([a-fA-F0-9][a-fA-F0-9])|', '', $new_username);
        $new_username = preg_replace('/&.?;/', '', $new_username); // Kill entities
    
       // If strict, reduce to ASCII for max portability.
       if ( $strict )
            $new_username = preg_replace('|[^a-z0-9 _.\-@+]|i', '', $new_username);
    
        return $new_username;
    }
    add_filter( 'sanitize_user', 'tubs_sanitize_user', 10, 3);

    Source

    Or try with this:

    // Force Strong Username
    function strong_username() {
     global $bp;
    
     if ( !empty( $_POST['signup_username'] ) )
       if ( !valid_username( $_POST['signup_username'] ) ){
        $bp->signup->errors['signup_username'] = __( 'Your username is not strong enough. Use uppercase, lowercase, numbers and special chars like - _', 'bp-strong-username-password', 'buddypress' );
       }
     }
     add_action( 'bp_signup_validate', 'strong_username');
    
     function valid_username($candidate) {
       $r1='/[A-Z]/';  //Uppercase 
       $r2='/[a-z]/';  //lowercase
       $r3='/[0-9]/';  //numbers
       $r4='/[-_]/'; //Special chars, underscore...
    
       if(preg_match_all($r1,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r2,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r3,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r4,$candidate, $o)<1) return FALSE;
       if(strlen($candidate)<6) return FALSE;
    
       return TRUE;
    }

    livingflame
    Participant

    @livingflame

    @r-a-y Help please!


    livingflame
    Participant

    @livingflame

    @r-a-y Help!


    livingflame
    Participant

    @livingflame

    Hi @henrywright

    Help me with the code.
    I need the Message button visible only to logged in users (Just like the Add Friend button works).

    Check the code.


    livingflame
    Participant

    @livingflame

    @udarmo

    You need to create an email in your Hosting.

    And next, config this email SMTP using Mail Bank Plugin.


    livingflame
    Participant

    @livingflame


    livingflame
    Participant

    @livingflame

    Hi @macpresss
    Thanks, but is_user_logged… does not work.


    livingflame
    Participant

    @livingflame

    Correction:

    <?php
    /*
    Plugin Name: BP strong username and password
    Description: Force the new registered in BuddyPress to use strong username and password.
    Version: 1.0
    Author: Anonymous
    */
    
    add_action( 'plugins_loaded', 'plugin_load_textdomain' );
    function plugin_load_textdomain() {
      load_plugin_textdomain( 'bp-strong-username-password', false, dirname( plugin_basename( __FILE__ ) ) . '/languages' ); 
    }
    
    // Force Strong Username
    function strong_username() {
     global $bp;
    
     if ( !empty( $_POST['signup_username'] ) )
       if ( !valid_username( $_POST['signup_username'] ) ){
        $bp->signup->errors['signup_username'] = __( 'Your username is too weak or short. Please, use uppercase, lowercase and numbers. Minimum 8 chars.', 'bp-strong-username-password', 'buddypress' );
       }
     }
     add_action( 'bp_signup_validate', 'strong_username');
    
     function valid_username($candidate) {
       $r1='/[A-Z]/';  //Uppercase 
       $r2='/[a-z]/';  //lowercase
       $r3='/[0-9]/';  //numbers
    
       if(preg_match_all($r1,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r2,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r3,$candidate, $o)<1) return FALSE;
       if(strlen($candidate)<8) return FALSE;
    
       return TRUE;
    }
    
    // Force Strong Password
    function strong_validation() {
     global $bp;
    
     if ( !empty( $_POST['signup_password'] ) )
       if ( !valid_pass( $_POST['signup_password'] ) ){
        $bp->signup->errors['signup_password'] = __( 'Your password is weak or too short. Please, use uppercase, lowercase, numbers and special characters. Minimum 8 chars.', 'bp-strong-username-password', 'buddypress' );
       }
     }
     add_action( 'bp_signup_validate', 'strong_validation');
    
     function valid_pass($candidate) {
       $r1='/[A-Z]/';  //Uppercase
       $r2='/[a-z]/';  //lowercase
       $r3='/[!@#$%^&*()-_=+{};:,?<.>]/';  // whatever you mean by special char
       $r4='/[0-9]/';  //numbers
    
       if(preg_match_all($r1,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r2,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r3,$candidate, $o)<1) return FALSE;
       if(preg_match_all($r4,$candidate, $o)<1) return FALSE;
       if(strlen($candidate)<8) return FALSE;
    
       return TRUE;
    }

    livingflame
    Participant

    @livingflame

    Extra CODE if you want. Put it in your functions.php:

    // Restricted Email Domains. Acept only valid email domains
    add_option('limited_email_domains', array('yahoo.com', 'outlook.com', 'hotmail.com', 'gmail.com', 'aol.com', 'mail.com'));

    livingflame
    Participant

    @livingflame

    If you have problem with Translation, Use the plugin Loco Translate to fix.


    livingflame
    Participant

    @livingflame

    // Restrict Private Message to friends.

    Does not work with the new BuddyPress. ;-/


    livingflame
    Participant

    @livingflame

    And this other, but optionally (allow members to choice):

    [√] Enable (marked by default)
    [ ] Disable

    // Disable Public Message 
    add_filter('bp_get_send_public_message_button', '__return_false');

    And exclude Admins for this rule.


    @r-a-y


    @shanebp


    livingflame
    Participant

    @livingflame

    @anthonylawton

    Create a plugin with this. But, if you use BuddyPress Honeypot, this plugin not work.

    <?php
    /*
    Plugin Name: Restricted Email Domains
    Description: Restricts registration user email addresses to valid domains.
    From: http://old.webit.ca/2011/03/limit-user-email-domains-in-buddypress/
    Version: 1.0
    */
    add_option('limited_email_domains', array('yahoo.com', 'outlook.com', 'hotmail.com', 'gmail.com', 'aol.com', 'mail.com')); 

    livingflame
    Participant

    @livingflame

    I found the solution:

    // Exclude Admins from Directories and BP Widgets 
    add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
     
    function buddydev_exclude_users( $args ) {
        //do not exclude in admin
        if( is_admin() && ! defined( 'DOING_AJAX' ) ) {
            return $args;
        }
        
        $excluded = isset( $args['exclude'] )? $args['exclude'] : array();
     
        if( !is_array( $excluded ) ) {
            $excluded = explode(',', $excluded );
        }
        
        $user_ids = array( 1, ); // enter user ids here
        
        
        $excluded = array_merge( $excluded, $user_ids );
        
        $args['exclude'] = $excluded;
        
        return $args;
    }
    
    // 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 );
    
    // 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 );
    
    

    livingflame
    Participant

    @livingflame

    Solution: HIDE ADMIN FROM BP WIDGETS AND DIRECTORY

    This code is complementary for the other ==>

    Hiding Users on BuddyPress based site

    So, full code:

    
    // Exclude Admin from Directories and BP Widgets 
    add_filter( 'bp_after_has_members_parse_args', 'buddydev_exclude_users' );
     
    function buddydev_exclude_users( $args ) {
        //do not exclude in admin
        if( is_admin() && ! defined( 'DOING_AJAX' ) ) {
            return $args;
        }
        
        $excluded = isset( $args['exclude'] )? $args['exclude'] : array();
     
        if( !is_array( $excluded ) ) {
            $excluded = explode(',', $excluded );
        }
        
        $user_ids = array( 1, ); // enter user ids here
        
        
        $excluded = array_merge( $excluded, $user_ids );
        
        $args['exclude'] = $excluded;
        
        return $args;
    }
    
    // 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 );
    
    // 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 );

    livingflame
    Participant

    @livingflame

Viewing 25 replies - 1 through 25 (of 57 total)
Skip to toolbar