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: 25331

    Hi Dale,
    Thank you for the question.

    This is a common issue and will be independent of the theme. I will post the reason and solution both.

    BuddyPress uses ‘heartbeat’ script as a dependency for loading the buddypress.js file(from theme/legacy pack).

    Most of the plugin remove heartbeat by de-registering ‘heartbeat’ dependency.

    Since the dependency is not met, the buddypress.js is not loaded and that has been causing the issue.

    You can resolve this by telling BuddyPress to not use heartbeat as a dependency by putting this code in bp-custom.php

    
    
    add_filter( 'bp_activity_do_heartbeat', '__return_false' );
    

    After that, clearing cache will make things work.

    Best regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25331

    You are welcome. I am glad it is juseful.

    Bet Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25331
    Brajesh Singh on in reply to: [Resolved] comment plugin #21115
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25331

    Hi,
    That will work.
    May I suggest using the following

    
    
    $table  = buddypress()->profile->table_name_data;
    $qry    = $wpdb->prepare( "SELECT value FROM {$table} WHERE field_id = %d AND value = %s", $field_id, $field );
    $result = $wpdb->get_var( $qry );
    
    

    instead of

    
    $qry = "SELECT value FROM wp_bp_xprofile_data WHERE value = " . $field;
        $result = $wpdb->get_results( $qry );
    

    It will work even when the prefix for database is different than wp_ and sanitizing the query is important to avoid any issue. Also, It limits the search for the value ot specific field id.

    Bets Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25331
    Brajesh Singh on in reply to: [Resolved] comment plugin #21108
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25331
    Brajesh Singh on in reply to: hide mediapress for simple users #21106

    Please use the following

    
    
    /**
     * Check if a user has given WordPress role(or any of the roles).
     *
     * @param int           $user_id user.
     * @param string|array  $role role(s).
     *
     * @return bool|array
     */
    function buddydev_user_has_role( $user_id, $role ) {
    	$user   = get_user_by( 'id', $user_id );
    
    	if ( empty( $user ) ) {
    		return false;
    	}
    
    	$user_roles = $user->roles;
    
    	if ( empty( $user_roles ) ) {
    		return false;
    	}
    	// if an array o roles was given.
    	return is_array( $role) ? array_intersect( $role, $user_roles ) : in_array( $role, $user_roles, true );
    }
    
    /**
     * Only allow galleries for a certain role.
     *
     * @param bool   $is_active Can create gallery or not.
     * @param string $component Component name.
     * @param int    $component_id Component id.
     *
     * @return bool
     */
    function buddydev_disable_gallery_for_roles( $is_active, $component, $component_id ) {
    
    	if ( 'members' !== $component ) {
    		return $is_active;
    	}
    
    	$restricted_roles = array( 'subscriber', 'contributor' );// 'editor', 'contributor', 'subscriber'
    
    	if ( buddydev_user_has_role( $component_id, $restricted_roles ) ) {
    		$is_active = false;
    	}
    
    	return $is_active;
    }
    add_filter( 'mpp_is_enabled', 'buddydev_disable_gallery_for_roles', 10, 3 );
    
    

    Please feel free to modify the roles list.

    Let me know if it works for you or not?

    PS:- The code should go to wp-content/plugins/bp-custom.php

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25331
    Brajesh Singh on in reply to: [Resolved] comment plugin #21105
    This reply has been marked as private.
  • Keymaster
    (BuddyDev Team)
    Posts: 25331

    Hi Leile,

    I don’t see any function that does it. It will be faster and simpler to write a query. If you want, I can do that for you.

    Thank you
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25331

    Hi Tosin,
    Yes, That will work 🙂

    You may remove the ‘exit’ line as ‘bp_core_redirect’ does it for us. Still, keeping it is not going to harm.

    Regards
    Brajesh

  • Keymaster
    (BuddyDev Team)
    Posts: 25331
    Brajesh Singh on in reply to: [Resolved] login redirect issues #21101

    Hi Mike,
    Marking resolved as you already fixed it(as per private message).

    Regards
    Brajesh