BuddyDev

Search

Replies

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52401

    Hello Sunny,

    Thank you for the acknowledgment. Please place the following code in the “bp-custom.php” file or your active theme “functions.php” file.

    
    add_shortcode( 'bp-activity-search-form', function ( $atts ) {
    
    	if ( ! function_exists( 'bp_get_activity_directory_permalink' ) ) {
    		return '';
    	}
    
    	$atts = shortcode_atts(
    		array(
    			'label'     => __( 'Search Activities', 'bp-custom' ),
    			'btn_label' => __( 'Search', 'bp-custom' ),
    		),
    		$atts
    	);
    
    	ob_start();
    
    	?>
    	<div class="bp-activity-search-form">
    		<?php if ( $atts['label'] ) : ?>
    			<h4><?php echo esc_html( $atts['label'] ); ?></h4>
    		<?php endif; ?>
    		<form action="<?php echo esc_url( bp_get_activity_directory_permalink() ); ?>" method="get">
    			<input type="text" name="s">
    			<input type="submit" class="button" value="<?php echo esc_attr( $atts['btn_label'] ); ?>">
    		</form>
    	</div>
    	<?php
    
    	return ob_get_clean();
    } );
    
    

    Please use the shortcode “[bp-activity-search-form]”. It only works with the activity directory page. Please give it a try and let me know.

    To more info on “bp-custom.php” check here: https://buddydev.com/docs/buddypress-guides/what-is-bp-custom-php/

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52358

    Hello Sunnybuddy,

    Thank you for the acknowledgement. As you said you are using the older BuddyPress which is why there is no activity search form in the latest version you can find it on the Activity directory page. But to check whether activity search is supported on your setup just try to add “?s=text-to-search” with the URL on the directory page and check whether it shows results or not. If it shows the expected result you can create a search form using HTML and make it searchable.

    Please give it a try.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52354
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52353
    This reply has been marked as private.
  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52352

    Hello La,

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

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52345

    Hello La,

    Thank you for the acknowledgement. I am glad that it worked. Just comment or delete the following code:

    
    else {
    		$settings['default_cover'] = 'http://example.com/cover.jpg';
    	}
    
    

    With this step, no default cover will apply if the user does not have the mentioned role in the conditions.

    Please check.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52341

    Hello Sunnybuddy,

    Welcome to the BuddyDev forums. Please let me know which theme or BuddyPress template pack you are using so that I can help. Also, let me know if you are using Youzify yes or no.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52340

    Hello La,

    Thank you for the acknowledgement. Please try the following code:

    
    
    /**
     * Default cover based on role
     *
     * @param array $settings Cover image settings.
     *
     * @return array
     */
    function buddydev_set_custom_default_profile_cover( $settings = array() ) {
    
    	if ( ! bp_is_user() ) {
    		return $settings;
    	}
    
    	$user = get_user_by( 'id', bp_displayed_user_id() );
    
    	if ( ! $user ) {
    		return $settings;
    	}
    
    	if ( in_array( 'administrator', $user->roles, true ) ) {
    		// Users with administrator role.
    		$settings['default_cover'] = 'http://example.com/cover-admin.jpg';
    	} elseif ( in_array( 'editor', $user->roles, true ) ) { //editor
    		// Users with editor role.
    		$settings['default_cover'] = 'http://example.com/cover-editor.jpg';
    	} elseif ( in_array( 'author', $user->roles, true ) ) { //author
    		// Users with author role.
    		$settings['default_cover'] = 'http://example.com/cover-author.jpg';
    	} elseif ( in_array( 'contributor', $user->roles, true ) ) {
    		// Users with contributor role.
    		$settings['default_cover'] = 'http://example.com/cover-contributor.jpg';
    	} elseif ( in_array( 'subscriber', $user->roles, true ) ) {
    		// Users with subscriber role.
    		$settings['default_cover'] = 'http://example.com/cover-subscriber.jpg';
    	} else {
    		$settings['default_cover'] = 'http://example.com/cover.jpg';
    	}
    
    	return $settings;
    }
    add_filter( 'bp_before_members_cover_image_settings_parse_args', 'buddydev_set_custom_default_profile_cover', 40 );
    
    

    Let me know if it helps or not.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52335

    Hello La,

    Thank you for posting. Please let me know your exact requirements so that I can help. Are you looking for role-based default cover images or any single default cover image that would apply to all the users without a cover image? Please let me know.

    Regards
    Ravi

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2935
    Ravi on #52334

    Hello La,

    Thank you for posting. You do not need any specific plugin to allow users to upload cover photos and avatars as it is there in the BuddyPress core plugin. There is a settings under Settings > BuddyPress > Options > Community Members in the backend and make sure “Profile Photo Uploads” and “Cover Image Uploads” are enabled.

    On frontend: You can see sub-tabs “Change Profile Photo” and “Change Cover Image” under the profile menu from there users are allowed to upload

    Regards
    ravi