BuddyDev

Search

Replies

  • Participant
    Level: Guru
    Posts: 903

    What about this

     function open_external_links_in_new_tab_bp_activity( $query_string, $object ) {
      if ( $object != 'activity' ) {
        return $query_string;
      }
      ?>
      <script type="text/javascript">
      var links = document.getElementsByTagName("a");
      for (var i = 0; i < links.length; i++) {
        var link = links[i];
        if (link.hostname != window.location.hostname) {
          link.target = "_blank";
        }
      }
      </script>
      <?php
      return $query_string;
    }
    add_filter( 'bp_ajax_querystring', 'open_external_links_in_new_tab_bp_activity', 10, 2 ); 
  • Participant
    Level: Guru
    Posts: 903

    I found this code

     function open_external_links_in_new_tab() {
      echo '<script type="text/javascript">';
      echo 'var links = document.getElementsByTagName("a");';
      echo 'for (var i = 0; i < links.length; i++) {';
      echo 'var link = links[i];';
      echo 'if (link.hostname != window.location.hostname) {';
      echo 'link.target = "_blank";';
      echo '}';
      echo '}';
      echo '</script>';
    }
    add_action( 'wp_footer', 'open_external_links_in_new_tab' ); 

    Kindly review

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: How to add condition to custom profile button #47714

    or maybe using a profile group id 4323 to identify CONTACT DETAILS profile group

     function bp_add_contact_button() {
    
    	// Check if the current user is logged in
    	if ( !is_user_logged_in() ) {
    		return;
    	}
    
    	// Get the current user's ID
    	$user_id = bp_displayed_user_id();
    
    	// Get the field data for the "Contact Information" profile group
    	$field_data = bp_get_profile_group_field_data( array( 'user_id' => $user_id, 'group_id' => 4323 ) );
    
    	// Check if the "Contact Information" profile group has at least one field updated
    	if ( !empty( $field_data ) ) {
    		$contact_user_button_args = array(
    			'id'                => 'contact_user',
    			'component'         => 'members',
    			'must_be_logged_in' => true,
    			'block_self'        => true,
    			'link_class'        => 'contact-user',
    			'link_href'         => esc_url( bp_displayed_user_domain() . bp_get_profile_slug() . '/#item-body' ),
    			'link_text'         => __( 'Contact Me' ),
    		);
    		echo bp_get_button( $contact_user_button_args );
    	}
    }
    add_action( 'bp_member_header_actions', 'bp_add_contact_button' ); 
  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: How to add condition to custom profile button #47713

    Hi Brajesh,

    Does this make any sense

     function bp_add_contact_button() {
    
    	// Check if the current user is logged in
    	if ( !is_user_logged_in() ) {
    		return;
    	}
    
    	// Get the current user's ID
    	$user_id = bp_displayed_user_id();
    
    	// Get the last updated timestamp for the "Contact Information" profile group
    	$last_updated = bp_get_user_meta( $user_id, 'bp_profile_group_contact_information_last_updated', true );
    
    	// Check if the "Contact Information" profile group has at least one field updated
    	if ( !empty( $last_updated ) ) {
    		$contact_user_button_args = array(
    			'id'                => 'contact_user',
    			'component'         => 'members',
    			'must_be_logged_in' => true,
    			'block_self'        => true,
    			'link_class'        => 'contact-user',
    			'link_href'         => esc_url( bp_displayed_user_domain() . bp_get_profile_slug() . '/#item-body' ),
    			'link_text'         => __( 'Contact Me' ),
    		);
    		echo bp_get_button( $contact_user_button_args );
    	}
    }
    add_action( 'bp_member_header_actions', 'bp_add_contact_button' ); 
  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: [Resolved] Buddyblog activity button #47683

    Hi I just noticed the the link also appears in the activities of other members instead of only displaying in the activity of the current logged in user

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: [Resolved] Buddyblog activity button #47681

    Thanks Ravi

     add_action( 'bp_activity_entry_meta', function () {
    	global $activities_template;
    
    	if ( 'new_classified' == $activities_template->activity->type ) {
    		echo "<a href='https://www.site.com/manage-listings/' class='advert-edit-link'>Manage / Edit Ad</a>";
    	}
    } );
  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: [Resolved] Buddyblog activity button #47665

    Sure Brajesh I will do as instructed

    Apologies for the inconvenience

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: [Resolved] Buddyblog activity button #47662

    Kind reminder sir thanks

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: Buddyblog delete attached media #47633

    Hello sir,

    Any resolution yet

    Thanks

  • Participant
    Level: Guru
    Posts: 903
    Tosin on in reply to: [Resolved] Buddyblog activity button #47626

    I’ll take to your advice thanks sir

    just one more support needed

    How can I also add another activity meta button in (new_classified) activities linking to this page (manage-listings), this button would only be displayed in the activity type (new_classified) and not (new_blog_post)

    Thanks