BuddyDev

Search

Replies

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: Force strong password when user change own password #42468

    Hello Torben,

    Please try the following code:

    
    
    /**
     * Validate password
     *
     * @param WP_Error $errors Error object.
     * @param string   $pass   Password.
     */
    add_filter( 'bp_members_validate_user_password', function ($errors, $pass ) {
    
    	if ( $errors->has_errors() ) {
    		return $errors;
    	}
    
    	$uppercase_exp    = '/[A-Z]/';
    	$lowercase_exp    = '/[a-z]/';
    	$special_char_exp = '/[!@#$%^&*()-_=+{};:,<.>]/';
    	$numeric_exp      = '/[0-9]/';
    
    	if ( preg_match_all( $uppercase_exp, $pass, $o ) < 1 ) {
    		// Check if password has one upper case letter.
    		$errors->add( 'missing_uppercase', __( 'Please make sure you enter your password twice', 'buddypress' ) );
    	} elseif ( preg_match_all( $lowercase_exp, $pass, $o ) < 1 ) {
    		// Check if password has one lower case letter.
    		$errors->add( 'missing_lowercase', __( 'Please make sure you enter your password twice', 'buddypress' ) );
    	} elseif ( preg_match_all( $special_char_exp, $pass, $o ) < 1 ) {
    		// Check if password has one special letter.
    		$errors->add( 'missing_special_char', __( 'Please make sure you enter your password twice', 'buddypress' ) );
    	} elseif ( preg_match_all( $numeric_exp, $pass, $o ) < 1 ) {
    		// Check if password has one numeric letter.
    		$errors->add( 'missing_numeric_char', __( 'Please make sure you enter your password twice', 'buddypress' ) );
    	} elseif ( strlen( $pass ) < 8 ) {
    		// Check if password has certain limit.
    		$errors->add( 'missing_char_limit', __( 'Please make sure you enter your password twice', 'buddypress' ) );
    	}
    
    	return $errors;
    }, 10, 2 );
    
    

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: Force strong password when user change own password #42465

    Hello Torben,

    Thank you for posting here. Please try the following filter used for validating the user password.

    
    bp_members_validate_user_password
    
    

    Let me know if it helps you or not.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: Recent Visitors, wrapping example code snippets #42464

    Hello Carsten,

    Thank you for posting. Function with name ‘visitors_show_my_recent_visitor’ will render the content from ‘recent-visitors/recent-visitors-header.php’ template file while function with name ‘visitors_get_recent_visitors’ will return the visitors for the user with how many to return threshold limit and for what period of time. you can use the result for your own custom loop.

    Please share your code so that I can assist you with the code.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115

    Hello Mike,

    Thank you for the acknowlegment. I am glad that I could help you.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115

    Hello Mike,

    Try the following code:

    
    
    add_action( 'bp_before_member_activity_post_form', function () {
    
    	if ( ! bp_is_user() || ! bp_is_user_activity() ) {
    		return;
    	}
    
    	?>
    
    		<label class="activity-filter-order">
    			<?php _e( 'Order' ) ?>
    			<select id="activity-filter-order">
    				<option value="DESC"><?php _e( 'Descending' ) ?></option>
    				<option value="ASC"><?php _e( 'Ascending' ) ?></option>
    			</select>
    		</label>
    	<?php
    } );
    
    add_filter( 'bp_ajax_querystring', function ( $query_string ) {
    
    	if ( ! bp_is_user() || ! bp_is_user_activity() ) {
    		return $query_string;
    	}
    
    	$sort = empty( $_POST['sort'] ) ? '' : wp_unslash( $_POST['sort'] );
    
    	if ( in_array( $sort, array( 'ASC', 'DESC' ) ) ) {
    		$query_string .= empty( $query_string ) ? "sort={$sort}" : "&sort={$sort}";
    	}
    
    	return $query_string;
    }, 99 );
    
    add_action( 'bp_enqueue_scripts', function () {
    
    	if ( ! bp_is_user() || ! bp_is_user_activity() ) {
    		return;
    	}
    
    	$data = "
    	jQuery( document ).ajaxSend(function( event, jqxhr, settings ) {
            if ( settings.data && settings.data.indexOf('action=activity_widget_filter') !== -1 ) {
    			settings.data += '&sort=' + jQuery('select#activity-filter-order').val();
    	    }
    	});
    	
    	jQuery(document).ready(function(){
    	    jQuery('#activity-filter-order').change(function() {
    		    jQuery('#activity-filter-by').trigger('change');
    	    })
    	})
    	";
    
    	wp_add_inline_script( 'bp-legacy-js', $data, 'before' );
    }, 11 );
    
    

    Please let me know if helps or not.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: Auto friendship list with conditions not working #42390

    Hello,

    Sorry for the inconvenience. Please let me when are you expecting the user should be auto friends with the list user e.q. at the registration or activation or changing member type from admin.

    I am assuming your associating member type is different from the member type given in the list condition because only in this case members will be auto friends with the user

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115

    Hello Isabelle,

    Thank you for the acknowledgment. I am glad to help you.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115

    Hello Mary,

    Please try the following code:

    
    add_filter( 'mpp_handle_upload', function ( $args, $context ) {
        apply_filters( 'wp_handle_upload', $args, $context );
    
        return $args;
    }, 10, 2 );
    
    add_filter( 'mpp_generate_metadata', function ( $meta_data, $attactment_id ) {
        apply_filters( 'wp_generate_attachment_metadata', $meta_data, $attactment_id, 'update' );
    
        return $meta_data;
    }, 10, 2 );
    
    

    In case you are using the Media Cloud plugin use the following code as well:

    
    add_filter( 'media-cloud/storage/should-handle-image-upload', '__return_true' );
    

    Please let me know if it works or not.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: [Resolved] How to create a template #42384

    Hello David,

    You may want to take a look at this

    https://codex.buddypress.org/themes/theme-compatibility-1-7/a-quick-look-at-1-7-theme-compatibility/

    That should help a little bit. There is not much available on template override other than it currently.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 3115
    Ravi on in reply to: mediapress #42382

    Hello Don,

    Welcome to the BuddyDev Forums. Check the following resource:

    https://buddydev.com/mediapress/shortcodes/mpp-list-media/

    Please check ‘Gallery Parameters’ for listing media from different galleries. We can not apply limits on media from different galleries with the current version of the shortcode.

    Please let me know if you need further assistance

    Regards
    Ravi