Shape the future of Social networking with WordPress: Join Project Midnight Sun! The next generation platform for community building with WordPress!

BuddyDev

Search

Replies

  • Keymaster
    (BuddyDev Team)
    Posts: 25318
    Brajesh Singh on in reply to: [Resolved] paiement with featured Member #18075
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25318

    Hi Tosin,
    I am sorry but we won’t be able to provide free support for 3rd part plugins except BuddyPress. If Ravi prefers, he may support you but I won’t be able to do it.

    If you want to implement the same with default BuddyPress message button, I will gladly help.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318
    Brajesh Singh on in reply to: BuddyPress XProfile fields #18069

    Hi Nate,
    I am sorry but I am unable to understand your question.

    Do you want to implement a custom loop instead of using BuddyPress profile data? If yes, you will need to implement it on your own.

    The two options for storing data can be user meta table or a custom table. If search is important, custom table should be preferred.

    If you plan to use user meta, you can use WordPress meta api. If you plan to go custom table route, you will need to know $wpdb for making database calls and you should most probably will need to know about the WordPress caching API for caching data.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318

    Hi Michael,
    No Problem. Let us change the code a bit.

    Step 1:- Please remove the old code for member type visibility and use the following

    
    
    /**
     * Get an array of member types enable for visibility.
     *
     * @return array
     */
    function buddydev_get_visibility_member_types() {
    
    	return array(
    		'recruiter',
    		'staff',
    	);
    }
    
    /**
     * Add extra visibility levels.
     *
     * @param array $visibilities visibilities.
     *
     * @return array
     */
    function buddydev_add_member_type_profile_visibility( $visibilities ) {
    
    	$member_types = bp_get_member_types( array(), 'object' );
    	// If there is no registered member type, return the original visibilities.
    	if ( empty( $member_types ) ) {
    		return $visibilities;
    	}
    
    	$allowed_member_types = buddydev_get_visibility_member_types();
    
    	// Add our member type as visibility levels.
    	foreach ( $member_types as $member_type => $member_type_object ) {
    
    		if ( ! in_array( $member_type, $allowed_member_types ) ) {
    			continue;
    		}
    
    		$visibilities[ $member_type ] = array(
    			'id'    => $member_type,
    			'label' => $member_type_object->labels['singular_name'],
    		);
    	}
    
    	return $visibilities;
    }
    
    add_filter( 'bp_xprofile_get_visibility_levels', 'buddydev_add_member_type_profile_visibility' );
    
    /**
     * Hide profile fields based on member type visibility.
     *
     * @param array $hidden_levels hidden visibility levels.
     * @param int   $displayed_user_id displayed user id.
     * @param int   $current_user_id logged in user id.
     *
     * @return array
     */
    function buddydev_get_hidden_visibility_types_for_user( $hidden_levels, $displayed_user_id, $current_user_id ) {
    
    	// Consider all listed member types as invisible.
    	$member_types = buddydev_get_visibility_member_types();
    
    	// If user is not logged in
    	// All member type visibilities will be hidden.
    	if ( ! is_user_logged_in() ) {
    		$hidden_levels = array_merge( $hidden_levels, $member_types );
    	} elseif ( ( $displayed_user_id == $current_user_id ) || is_super_admin( $current_user_id ) ) {
    		// Do not hide anything on own profile or viewed by super admin.
    	} else {
    		// User is logged in and viewing other user's profile.
    		$logged_member_types = bp_get_member_type( $current_user_id, false );
    		// except current user's member type, all other levels will be hidden.
    		if ( $logged_member_types ) {
    			$member_types = array_diff( $member_types, $logged_member_types );
    		}
    
    		$hidden_levels = array_merge( $hidden_levels, $member_types );
    	}
    
    	return $hidden_levels;
    }
    
    add_filter( 'bp_xprofile_get_hidden_field_types_for_user', 'buddydev_get_hidden_visibility_types_for_user', 10, 3 );
    
    

    Now, in order to limit to only certain member types, all you have to do is change this

    
    
    	return array(
    		'recruiter',
    		'staff',
    	);
    
    

    Change the values in this array with the actual member type name(unique name).

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318
    Brajesh Singh on in reply to: facebook like activity stream #18067

    Hi David,

    1. Yes. You will need to enable it in the settings of the plugin though.
    2. Please use the following code.

    
    
    /**
     * Redirect user on login.
     *
     * @param string  $redirect_to_calculated the page where user is about to be redirected.
     * @param string  $redirect_url_specified actual specified redirect.
     * @param WP_User $user user.
     *
     * @return string
     */
    function buddydev_redirect_on_login( $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();
    	}
    
    	// Where do you want to redirect.
    	//  You can change it to anything.
    	$redirect_to = bp_core_get_user_domain( $user->ID );
    	
    	// for example, to redirect to user's group page, you will use
    	// $redirect_to = bp_core_get_user_domain( $user->ID ) . 'groups/';
    
    	return $redirect_to;
    }
    
    add_filter( 'login_redirect', 'buddydev_redirect_on_login', 101, 3 );
    
    

    The above code redirects to profile. You can change $redirect_to to point to anywhere.
    For example, To redirect to member directory, you can change it to.

    
    $redirect_to = bp_get_activity_directory_permalink();
    
    

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318

    Hi Carsten,
    I have looked into it. There is a bug in bp_member_profile_data and it does not passes the field id. Since the field id is not available, the custom fields plugin is unable to know whether age is required or date.

    There is a solution. Inside the members loop you can use

    
    <?php echo xprofile_get_field_data( 'Date Field Name', bp_get_member_user_id()  );?>
    
    

    That will give the correct data.
    For efficiency, you can replace the field name with id too.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318
    Brajesh Singh on in reply to: [Resolved] Moderation tools support for posts? #18064

    Hi Richard,
    Hope you are doing well.

    We will be most probably releasing the posts support today or tomorrow. It is in testing phase and I am looking forward to release within next 24-48 hours.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318

    Hi Michael,
    I am sorry for the confusion.

    You don’t need to change anything in the code. It is not working as it is unable to find the labels[‘Recruiter’]

    Is your goal to limit the available visibilities to only certain member types(like only Recruiter is available as a visibility level?)

    The code in the blog post will automatically take the singular label for all member types.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318
    Brajesh Singh on in reply to: facebook like activity stream #18060

    Hi David ,
    Thank you for asking.

    The current version allows you to select which activities you want to convert into stream.

    – You can use sitewide activity directory as the friends/groups/users stream
    – You can add extra tab on profile for stream.

    Both are optional and you can chose any on or both.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25318

    Hi Ravi,
    Thank you for the help here.


    @teeboy
    , I hope it works.

    Regards
    Brajesh