Skip to:
Content
Pages
Categories
Search
Top
Bottom

Forum Replies Created

Viewing 25 replies - 1 through 25 (of 1,492 total)
  • Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    <?php 
    $country = bp_get_member_profile_data( 'field=Country' );
    if ( $country != false ) {
        
        $href = site_url() . '/members/?s=' . $country . '&members_search_submit=Search';
    
        echo '<a href="' . $href . '">' . $country . '</a>';
    }
    ?>
    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Try:
    $href = site_url() . '/members/?s=' . bp_member_profile_data( 'field=Country' ) . '&members_search_submit=Search';

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Probably a javascript conflict. Check your browser console.

    In general, it’s best to use wp_editor instead of ckeditor.

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    a:3:{i:0;s:7:”English”;i:1;s:4:”Math”;i:2;s:10:”Substitute”;}
    is a serialized array.

    BuddyPress will unserialize profile data via
    xprofile_get_field_data( $field, $user_id = 0, $multi_format = 'array' )
    and return an array.

    But if you want to do this in the context of a search query, you probably want to use wildcards in the mysql statement, for example: %math%.
    This can be tricky to implement if you haven’t done it before.

    There is already a good plugin that does member searches based on profile field values:
    https://wordpress.org/plugins/bp-profile-search/

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Please use the code button when posting code.

    You need to include the default_subnav_slug field in bp_core_new_nav_item:
    https://gist.github.com/shanebp/5d3d2f298727a0a036e5

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Use this instead, and you won’t need the global $bp:
    bp_displayed_user_id();

    run during ‘init’ action

    That hook may run too early.
    Run it on a function hooked to bp_ready.

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    I need page ID of current BP page

    Which, as you’ve noted, will be 0.
    And don’t expect that to change any time soon, if ever.

    If you want to know which BP page you are on, via a boolean, see:
    https://codex.buddypress.org/developer/template-tag-reference/

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    You want to detect if they are on a non-BP page?
    Try using

    bp_is_blog_page() 
    return bool True if it's a non-BP page, false otherwise.
    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Please use the code button when posting code.

    …when you want to call actions associated with specific post/page

    What are you trying to do with action calls?

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    It would be nice if there was an apply_filter hook before the check of the allow_duplicate field.

    If you are adding a custom notification, then sending in a true value is easy.
    But there is no feasible way for existing functions, afaik, to filter the calls to bp_notifications_add_notification.

    Adding the filter hook in bp_notifications_add_notification is simple.
    But will require submitting an enhancement ticket.

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    $count  = // code that retrieves the count
    $class  = ( 0 === $count ) ? 'no-count' : 'count';
    
    bp_core_new_nav_item( array(
        'name'  =>  sprintf( __( 'Animals <span class="%s">%s</span>', 'lang-domain' ), esc_attr( $class ), number_format_i18n( $count ) ),
        // etc
    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    bp_core_load_template( 'template_content' );

    should be

    bp_core_load_template( apply_filters( 'bp_core_template_plugin', 'members/single/plugins' ) );

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Forums are handled by the bbPress plugin.
    Have you tried asking your question on the bbPress support forums?

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Use bp_get_friend_ids( bp_loggedin_user() ) to get the friend ids.

    Then use the result in the exclude parameter in bp_has_members.

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    According to codex –

    When using a loop on a members profile use user_id=0 to show non-friends of the displayed user.

    Where did you see that in the codex?

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Is there a better way of doing it?

    If we don’t have that plugin, we don’t know if there is a better way.
    If that code is working for you, great.

    bp_is_my_profile() returns a boolean value. So all you need is:

    if ( bp_is_my_profile() ) {

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    No offense, but there are too many basic mistakes in your code to enumerate them.

    Untested, but try:

    function bio_profile_field(){
        $user_id = bp_loggedin_user_id();
        $bio = xprofile_get_field_data( 5, $user_id, 'comma' ); 
        ?>
        
       <div id="primary" class="widget-area" role="complementary">
    
            <h3>Bio</h3>
            <hr />
            <form action="" method="post">
            
                <input type="hidden" name="edit_bio" value="1">
                
                <textarea rows="5" cols="26" name="edit_bio_text">
                    <?php echo $bio; ?>
                </textarea>
                
                <input type="submit" name="likesubmit" value="SAVE">
            </form>    
        </div>
        
    <?php
    }
    
    function yadigit_save_bio() {
    
    	if( isset( $_POST["edit_bio"]) && $_POST["edit_bio"] == '1' ) ){
    	
    		$user_id = bp_loggedin_user_id();
    		
    		$value = sanitize_text_field( $_POST["edit_bio_text"] );
    		
    		$field = 5;
    		
    		xprofile_set_field_data( $field, $user_id, $value, false );
    	        
    	}
    }
    add_action( 'wp', 'yadigit_save_bio' );
    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Why do you need the $bp global?

    Use the function meant for setting profile field data, and then you don’t need the $wpdb global either.
    http://stackoverflow.com/questions/12312372/how-to-update-custom-profile-field-data-in-buddypress

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    That is a premium plugin – you should ask the plugin author or whoever you paid for support.

    What you want should be simple to do – but unless somebody here has also paid for that plugin, nobody will be able to give you a definitive answer.

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Please use the code button when posting code.

    Here is a better approach, imo:

    function is_user_online( $user_id, $time=5 ) {
    
       $last_activity = bp_get_user_last_activity( $user_id );
    
       $curr_time = time(); 
    
       $diff = $curr_time - strtotime( $last_activity );
    
       $time *= 60;  // must be in seconds
    
       if( $diff < $time )
          return true;
       else 
          return false;
    }
    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Got a chance to revisit this…

    Both versions are now components.

    BuddyPress Simple Events in the WP repo.

    BuddyPress Simple Events Pro now has options for an Attending button, list of attendees, and notifications. As well as image support and Group assignment options.

    Re themes: the templates have been tested with included WP themes. If there is an issue with a particular theme, the templates can be overloaded and adjusted as necessary. The layouts are bare-bones, iow. very basic layouts.

    Re comment syncing: unfortunately, comment syncing is broken in BP 2.2.1. See tickets 6306 and 6294

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Please , no duplicates.

    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    Please use the code button when posting code.

    You can’t over-ride that function, but if you aren’t using multisite, you can use the filter hook:
    apply_filters( 'bp_core_validate_user_signup', $result );
    Which only provides one argument: $result

    So your function should be :

    add_filter('bp_core_validate_user_signup', 'validate_user_signup', 10, 1);
    function validate_user_signup($result) {
      // access to the user name: $result['user_name']
      // access to the user email: $result['user_email']
      //what is in errors: var_dump( $result['errors'] )
      return $result;
    }
    Profile photo of shanebp
    shanebp
    Moderator

    @shanebp

    WP allows registrations without using BP.

    Do you not want any registrations?
    If so, did you turn off ‘Anyone can register’ in
    [your site]/wp-admin/options-general.php ?

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