Skip to:
Content
Pages
Categories
Search
Top
Bottom

Create links to Buddypress pages


  • chris19731973
    Participant

    @chris19731973

    Hello,

    I have installed BuddyPress and a Classified ads plugin, There is no link/relation between this Classified and BP …
    On the single listing pages of the classified ads, I would like to add a link “VIEW (author USERNAME) PROFILE”.
    When visitors will click on this link, then they will be redirected to the bp profile page of the author who post the listing.
    Please I need codes or a plugin to add a link to BP page.

    Thanks in advance,

    Chris

Viewing 6 replies - 1 through 6 (of 6 total)

  • chris19731973
    Participant

    @chris19731973

    For instance, I could add a shortcode in the listing page …


    Prashant Singh
    Participant

    @prashantvatsh

    Hi,

    Please check this plugin: https://wordpress.org/plugins/bp-profile-shortcodes-extra/

    Thanks


    chris19731973
    Participant

    @chris19731973

    Thank you for the plugin … but it doesn’t work for me …
    Each single listing is a post with the code below
    I will need to add php codes to Create a linkk to Buddypress user profile


    chris19731973
    Participant

    @chris19731973

    <?php
    
    /**
     * Listing detail Page.
     *
     * @link    https://pluginsware.com
     * @since   1.0.0
     *
     * @package Advanced_Classifieds_And_Directory_Pro
     */
     
    // Exit if accessed directly
    if ( ! defined( 'WPINC' ) ) {
    	die;
    }
    
    /**
     * ACADP_Public_Listing Class.
     *
     * @since 1.0.0
     */
    class ACADP_Public_Listing {
    	
    	/**
    	 * Filter the post content.
    	 *
    	 * @since  1.5.4
    	 * @param  string $html The post thumbnail HTML.
    	 * @return string $html Filtered thumbnail HTML.
    	 */
    	public function post_thumbnail_html( $html ) {	
    		if ( is_singular( 'acadp_listings' ) ) {
    			return '';
    		}
    		
    		return $html;		
    	}
    	
    	/**
    	 * Filter the post content.
    	 *
    	 * @since  1.0.0
    	 * @param  string $content Content of the current post.
    	 * @return string $content Modified Content.
    	 */
    	public function the_content( $content ) {		
    		if ( is_singular( 'acadp_listings' ) && in_the_loop() && is_main_query() ) {		
    			global $post;
    			
    			acadp_update_listing_views_count( $post->ID );
    			
    			$general_settings      = get_option( 'acadp_general_settings' );
    			$recaptcha_settings    = get_option( 'acadp_recaptcha_settings' );	
    			$registration_settings = get_option( 'acadp_registration_settings' );
    
    			$post_meta = get_post_meta( $post->ID );
    			
    			$description = $content;
    					
    			$can_show_date         = isset( $general_settings['display_options'] ) && in_array( 'date', $general_settings['display_options'] )  ? true : false;
    			$can_show_user         = isset( $general_settings['display_options'] ) && in_array( 'user', $general_settings['display_options'] )  ? true : false;
    			$can_show_views        = isset( $general_settings['display_options'] ) && in_array( 'views', $general_settings['display_options'] ) ? true : false;
    			$can_show_contact_form = empty( $general_settings['has_contact_form'] ) ? false : true;	
    			$can_add_favourites    = empty( $general_settings['has_favourites'] )   ? false : true;
    			$can_report_abuse      = empty( $general_settings['has_report_abuse'] ) ? false : true;
    			$has_widgets           = acadp_has_active_listing_widgets();
    			$has_sidebar           = ! $has_widgets;
    			
    			// $login_url
    			$current_page_url = get_permalink();
    			$login_url        = acadp_get_user_login_page_link( $current_page_url );
    			
    			// $location
    			$has_location = empty( $general_settings['has_location'] ) ? false : true;
    			$can_show_location = false;
    			
    			if ( $has_location ) {
    				$location = wp_get_object_terms( $post->ID, 'acadp_locations' );
    			
    				if ( ! empty( $location ) ) {
    					$location = $location[0];
    					$can_show_location = true;
    				}
    			}
    			
    			// $category
    			$has_category = false;
    			$can_show_category = isset( $general_settings['display_options'] ) && in_array( 'category', $general_settings['display_options'] ) ? true : false;
    			$can_show_category_desc = isset( $general_settings['display_options'] ) && in_array( 'category_desc', $general_settings['display_options'] ) ? true : false;
    			$categories = wp_get_object_terms( $post->ID, 'acadp_categories' );
    			
    			if ( empty( $categories ) ) {
    				$can_show_category = false;
    			} else {
    				$category = $categories[0];
    				$has_category = true;
    			}
    			
    			// $can_show_images
    			$has_images = empty( $general_settings['has_images'] ) ? false : true;
    			$can_show_images = false;
    			
    			if ( $has_images ) {
    				$can_show_images = isset( $post_meta['images'] ) ? true : false;
    			}
    			
    			// $can_show_video
    			$has_video = empty( $general_settings['has_video'] ) ? false : true;
    			$can_show_video = false;
    			$video_url = '';
    			
    			if ( $has_video ) {
    				if ( ! empty( $post_meta['video'][0] ) ) {
    					$video_url = acadp_parse_videos( $post_meta['video'][0] );	
    					$can_show_video = empty( $video_url ) ? false : true;				
    				}				
    			}
    			
    			// $can_show_map
    			$has_map = ! empty( $general_settings['has_map'] ) && empty( $post_meta['hide_map'][0] ) ? true : false;
    			$can_show_map = false;
    		
    			if ( $can_show_location && $has_map ) {			
    				$can_show_map = ! empty( $post_meta['latitude'][0] ) && ! empty( $post_meta['longitude'][0] ) ? true : false;
    			}
    
    			// $can_show_price
    			$has_price = empty( $general_settings['has_price'] ) ? false : true;
    			$can_show_price = false;
    		
    			if ( $has_price && isset( $post_meta['price'] ) && $post_meta['price'][0] > 0 ) {
    				$can_show_price = true;
    			}
    			
    			// Get custom fields
    			$fields = array();
    			$category_ids = array();
    
    			foreach ( $categories as $category ) {
    				$category_ids[] = $category->term_id;
    			}
    
    			$custom_field_ids = acadp_get_custom_field_ids( $category_ids );	
    					
    			if ( ! empty( $custom_field_ids ) ) {
    				$args = array(
    					'post_type' => 'acadp_fields',
    					'post_status' => 'publish',
    					'posts_per_page' => 500,	
    					'post__in' => $custom_field_ids,
    					'no_found_rows' => true,
    					'update_post_term_cache' => false,	
    					'meta_key' => 'order',
    					'orderby' => 'meta_value_num',				
    					'order' => 'ASC'
    				);
    				
    				$acadp_query = new WP_Query( $args );
    
    				if ( $acadp_query->have_posts() ) {
    					$fields = $acadp_query->posts;
    				}
    			}
    
    			// Process output
    			ob_start();
    			do_action( 'acadp_before_listing_content' );
    			include( acadp_get_template( "listing/acadp-public-listing-display.php" ) );
    			do_action( 'acadp_after_listing_content' );
    			$content = ob_get_clean();		
    		}
    		
    		return $content;		
    	}
    	
    	/**
    	 * Add or Remove favourites.
    	 *
    	 * @since 1.0.0
    	 */
    	public function ajax_callback_add_remove_favorites() {	
    		check_ajax_referer( 'acadp_ajax_nonce', 'security' );
    
    		$post_id = (int) $_POST['post_id'];
    		
    		$favourites = (array) get_user_meta( get_current_user_id(), 'acadp_favourites', true );
    		
    		if ( in_array( $post_id, $favourites ) ) {			
    			if ( ( $key = array_search( $post_id, $favourites ) ) !== false ) {
        			unset( $favourites[ $key ] );
    			}
    		} else {
    			$favourites[] = $post_id;
    		}
    		
    		$favourites = array_filter( $favourites );
    		$favourites = array_values( $favourites );
    		
    		delete_user_meta( get_current_user_id(), 'acadp_favourites' );
    		update_user_meta( get_current_user_id(), 'acadp_favourites', $favourites );
    		
    		the_acadp_favourites_link( $post_id );
    		
    		wp_die();	
    	}
    	
    	/**
    	 * Report Abuse.
    	 *
    	 * @since 1.0.0
    	 */
    	public function ajax_callback_report_abuse() {	
    		check_ajax_referer( 'acadp_ajax_nonce', 'security' );
    
    		$data = array( 'error' => 0 );
    		
    		if ( acadp_is_human('report_abuse') ) {		
    			if ( acadp_email_admin_report_abuse() ) {			
    				$data['message'] = __( 'Your message sent successfully.', 'advanced-classifieds-and-directory-pro' );				
    			} else {				
    				$data['error']   = 1;
    				$data['message'] = __( 'Sorry! Please try again.', 'advanced-classifieds-and-directory-pro' );				
    			}			
    		} else {		
    			$data['error']   = 1;
    			$data['message'] = __( 'Invalid Captcha: Please try again.', 'advanced-classifieds-and-directory-pro' );			
    		}
    				
    		echo wp_json_encode( $data );
    		wp_die();	
    	}
    	
    	/**
    	 * Send contact email.
    	 *
    	 * @since 1.0.0
    	 */
    	public function ajax_callback_send_contact_email() {	
    		check_ajax_referer( 'acadp_ajax_nonce', 'security' );
    		
    		$data = array( 'error' => 0 );
    		
    		if ( acadp_is_human('contact') ) {		
    			if ( acadp_email_listing_owner_listing_contact() ) {			
    				// Send a copy to admin( only if applicable ).
    				acadp_email_admin_listing_contact();
    				
    				$data['message'] = __( 'Your message sent successfully.', 'advanced-classifieds-and-directory-pro' );				
    			} else {				
    				$data['error']   = 1;
    				$data['message'] = __( 'Sorry! Please try again.', 'advanced-classifieds-and-directory-pro' );				
    			}			
    		} else {		
    			$data['error']   = 1;
    			$data['message'] = __( 'Invalid Captcha: Please try again.', 'advanced-classifieds-and-directory-pro' );			
    		}
    			
    		echo wp_json_encode( $data );	
    		wp_die();	
    	}
    
    }
    

    chris19731973
    Participant

    @chris19731973

    Sorry, previously I pasted the wrong php file ….
    Please find below the current php code :


    chris19731973
    Participant

    @chris19731973

    <?php
    
    /**
     * This template displays the listing detail page content.
     *
     * @link    https://pluginsware.com
     * @since   1.0.0
     *
     * @package Advanced_Classifieds_And_Directory_Pro
     */
    ?>
    
    <div class="acadp acadp-listing">
    	<div class="row">    	
            <!-- Main content -->
            <div class="<?php echo $has_sidebar ? 'col-md-8' : 'col-md-12'; ?>">  
            	<!-- Header -->      
                <div class="pull-left acadp-post-title">        	
                    <h1 class="acadp-no-margin"><?php echo esc_html( $post->post_title ); ?></h1>
                    <?php the_acadp_listing_labels( $post_meta ); ?>
                    <?php				
                    $usermeta = array();
                    
                    if ( $can_show_date ) {
                        $usermeta[] = sprintf( esc_html__( 'Posted %s ago', 'advanced-classifieds-and-directory-pro' ), human_time_diff( get_the_time( 'U' ), current_time( 'timestamp' ) ) );
                    }
                                
                    if ( $can_show_user ) {			
                        $usermeta[] = '<a href="' . esc_url( acadp_get_user_page_link( $post->post_author ) ) . '">' . get_the_author() . '</a>';
                    }
                    
                    $meta = array();
                    
                    if ( $can_show_category ) {
                        $category_links = array();
                        foreach ( $categories as $category ) {						
                            $category_links[] = sprintf( '<a href="%s">%s</a>', esc_url( acadp_get_category_page_link( $category ) ), esc_html( $category->name ) );						
                        }
                        $meta[] = sprintf( '<span class="glyphicon glyphicon-briefcase"></span>&nbsp;%s', implode( ', ', $category_links ) );
                    }
    
                    if ( count( $usermeta ) ) {
                        $meta[] = implode( ' ' . esc_html__( 'by', 'advanced-classifieds-and-directory-pro' ) . ' ', $usermeta );
                    }
                    
                    if ( $can_show_views ) {
                        $meta[] = sprintf( esc_html__( "%d views", 'advanced-classifieds-and-directory-pro' ), $post_meta['views'][0] );
                    }
                    
                    if ( count( $meta ) ) {
                        echo '<small class="text-muted">' . implode( ' / ', $meta ) . '</small>
    ';
                    }
                    ?>
                </div>
                
                <!-- Price -->
                <?php if ( $can_show_price ) : ?>
                    <div class="pull-right text-right acadp-price-block">
                        <?php
                        $price = acadp_format_amount( $post_meta['price'][0] );						
                        echo '<p class="lead acadp-no-margin">' . esc_html( acadp_currency_filter( $price ) ) . '
    ';
                        ?>
                    </div>
                <?php endif; ?>
                
                <div class="clearfix"></div>
                
                <!-- Image(s) -->
                <?php if ( $can_show_images ) : $images = unserialize( $post_meta['images'][0] ); ?>
    				<?php if ( 1 == count( $images ) ) : $image_attributes = wp_get_attachment_image_src( $images[0], 'large' ); ?>
                        <img src="<?php echo esc_url( $image_attributes[0] ); ?>" />
    
                    <?php else : ?>
                        <div id="acadp-slider-wrapper">                       
                            <!-- Slider for -->
                            <div class="acadp-slider-for">
                                <?php foreach ( $images as $index => $image ) : $image_attributes = wp_get_attachment_image_src( $images[ $index ], 'large' ); ?>
                                	<div class="acadp-slider-item">
                                        <div class="acadp-responsive-container">
                                            <img src="<?php echo esc_url( $image_attributes[0] ); ?>" class="acadp-responsive-item" />
                                        </div>
                                    </div>
                                <?php endforeach; ?>
                            </div>
                            
                            <!-- Slider nav -->
                            <div class="acadp-slider-nav">
                                <?php foreach ( $images as $index => $image ) : $image_attributes = wp_get_attachment_image_src( $images[ $index ], 'thumbnail' ); ?>
                                    <div class="acadp-slider-item">
                                        <div class="acadp-slider-item-inner">
                                            <img src="<?php echo esc_url( $image_attributes[0] ); ?>" />
                                        </div>
                                    </div>
                                <?php endforeach; ?>
                            </div>        
                        </div>
                    <?php endif; ?> 
                <?php endif; ?>
                
                <!-- Description -->
                <?php echo wp_kses_post( $description ); ?>
                
                <!-- Custom fields -->
                <?php if ( count( $fields ) ) : ?>
                    <ul class="list-group acadp-margin-bottom">
                        <?php foreach ( $fields as $field )  : ?>                
                            <?php if ( ! empty( $post_meta[ $field->ID ][0] ) ) : ?>
                                <li class="list-group-item acadp-no-margin-left acadp-field-<?php echo esc_attr( $field->type ); ?>">
                                    <span class="text-primary"><?php echo esc_html( $field->post_title ); ?></span> :
                                    <span class="text-muted">
                                        <?php 
                                        $value = acadp_get_custom_field_display_text( $post_meta[ $field->ID ][0], $field );
                                        
                                        if ( 'textarea' == $field->type ) {
                                            echo wp_kses_post( nl2br( $value ) );
                                        } elseif ( 'url' == $field->type ) {
                                            echo wp_kses_post( $value );
                                        } else {
                                            echo esc_html( $value );
                                        }
                                        ?>
                                    </span>
                                </li>
                            <?php endif; ?>                    
                        <?php endforeach; ?>
                    </ul>
                <?php endif; ?>
                
                <!-- Footer -->
                <?php if ( $can_show_user || $can_add_favourites || $can_report_abuse ) : ?>
                    <ol class="breadcrumb">
                        <?php if ( $can_show_user ) : ?>
                            <li class="acadp-no-margin">			
                                <a href="<?php echo esc_url( acadp_get_user_page_link( $post->post_author ) ); ?>"><?php esc_html_e( 'Check all listings by this user', 'advanced-classifieds-and-directory-pro' ); ?></a>
                            </li>
                        <?php endif; ?>
                            
                        <?php if ( $can_add_favourites ) : ?>
                            <li id="acadp-favourites" class="acadp-no-margin"><?php the_acadp_favourites_link(); ?></li>
                        <?php endif; ?>
                            
                        <?php if ( $can_report_abuse ) : ?>
                            <li class="acadp-no-margin">
                                <?php if ( is_user_logged_in() ) { ?>
                                    <a href="#" data-toggle="modal" data-target="#acadp-report-abuse-modal"><?php esc_html_e( 'Report abuse', 'advanced-classifieds-and-directory-pro' ); ?></a>
                                        
                                    <!-- Modal (report abuse form) -->
                                    <div class="modal fade" id="acadp-report-abuse-modal" tabindex="-1" role="dialog" aria-labelledby="acadp-report-abuse-modal-label">
                                        <div class="modal-dialog" role="document">
                                            <div class="modal-content">
                                                <form id="acadp-report-abuse-form" class="form-vertical" role="form">
                                                    <div class="modal-header">
                                                        <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
                                                        <h3 class="modal-title" id="acadp-report-abuse-modal-label"><?php esc_html_e( 'Report Abuse', 'advanced-classifieds-and-directory-pro' ); ?></h3>
                                                    </div>
                                                    <div class="modal-body">
                                                        <div class="form-group">
                                                            <label for="acadp-report-abuse-message"><?php esc_html_e( 'Your Complaint', 'advanced-classifieds-and-directory-pro' ); ?><span class="acadp-star">*</span></label>
                                                            <textarea class="form-control" id="acadp-report-abuse-message" rows="3" placeholder="<?php esc_attr_e( 'Message', 'advanced-classifieds-and-directory-pro' ); ?>..." required></textarea>
                                                        </div>
                                                        <div id="acadp-report-abuse-g-recaptcha"></div>
                                                        <div id="acadp-report-abuse-message-display"></div>
                                                    </div>
                                                    <div class="modal-footer">
                                                        <button type="button" class="btn btn-default" data-dismiss="modal"><?php esc_html_e( 'Close', 'advanced-classifieds-and-directory-pro' ); ?></button>
                                                        <button type="submit" class="btn btn-primary"><?php esc_html_e( 'Submit', 'advanced-classifieds-and-directory-pro' ); ?></button>
                                                    </div>
                                                </form>
                                            </div>
                                        </div>
                                    </div>
                                <?php } else { ?>
                                    <a href="#" class="acadp-require-login"><?php esc_html_e( 'Report abuse', 'advanced-classifieds-and-directory-pro' ); ?></a>
                                <?php } ?>
                            </li>
                        <?php endif; ?>
                    </ol>
                <?php endif; ?>
            </div>
            
            <!-- Sidebar -->
            <?php if ( $has_sidebar ) : ?>
                <div class="col-md-4">
                	<!-- Video -->
                    <?php if ( $can_show_video ) : ?>
                    	<div class="acadp-margin-bottom">
                            <div class="embed-responsive embed-responsive-16by9">
                                <iframe class="embed-responsive-item" src="<?php echo esc_url( $video_url ); ?>" allowfullscreen></iframe>
                            </div>
                        </div>
                    <?php endif; ?> 
                    
                    <!-- Map & Address -->
                    <?php if ( $has_location ) : ?>
                    	<fieldset>
                        	<legend><?php esc_html_e( 'Contact details', 'advanced-classifieds-and-directory-pro' ); ?></legend>
    						<?php if ( $can_show_map ) : ?>
                                <div class="embed-responsive embed-responsive-16by9 acadp-margin-bottom">
                                    <div class="acadp-map embed-responsive-item">
                                        <div class="marker" data-latitude="<?php echo esc_attr( $post_meta['latitude'][0] ); ?>" data-longitude="<?php echo esc_attr( $post_meta['longitude'][0] ); ?>"></div> 
                                    </div>
                                </div>
                            <?php endif; ?>
                            
                            <!-- Address -->
                            <?php 
                            $location_id = ! empty( $location ) ? $location->term_id : 0;
                            the_acadp_address( $post_meta, $location_id ); 
                            ?>
                        </fieldset>
                    <?php endif; ?>
                    
                    <!-- Contact form -->
                    <?php if ( $can_show_contact_form ) : ?>
                    	<fieldset>
                        	<legend><?php esc_html_e( 'Contact this listing owner', 'advanced-classifieds-and-directory-pro' ); ?></legend>
    						<?php if ( ! empty( $general_settings['contact_form_require_login'] ) && ! is_user_logged_in() ) { ?> 
                                <p class="text-muted">
                                    <?php 
    									if ( 'acadp' == $registration_settings['engine'] ) {
    										printf( esc_html__( 'Please, <a href="%s">login</a> to contact this listing owner.', 'advanced-classifieds-and-directory-pro' ), esc_url( $login_url ) );
    									} else {
    										esc_html_e( 'Please, login to contact this listing owner.', 'advanced-classifieds-and-directory-pro' );
    									}
    								?>
                                
    
                            <?php } else { ?>
                                <form id="acadp-contact-form" class="form-vertical" role="form">
                                    <div class="form-group">
                                        <label for="acadp-contact-name"><?php esc_html_e( 'Your Name', 'advanced-classifieds-and-directory-pro' ); ?><span class="acadp-star">*</span></label>
                                        <input type="text" class="form-control" id="acadp-contact-name" placeholder="<?php esc_attr_e( 'Name', 'advanced-classifieds-and-directory-pro' ); ?>" required />
                                    </div>
                                    
                                    <div class="form-group">
                                        <label for="acadp-contact-email"><?php esc_html_e( 'Your E-mail Address', 'advanced-classifieds-and-directory-pro' ); ?><span class="acadp-star">*</span></label>
                                        <input type="email" class="form-control" id="acadp-contact-email" placeholder="<?php esc_attr_e( 'Email', 'advanced-classifieds-and-directory-pro' ); ?>" required />
                                    </div>  						
                                    
                                    <div class="form-group">
                                        <label for="acadp-contact-message"><?php esc_html_e( 'Your Message', 'advanced-classifieds-and-directory-pro' ); ?><span class="acadp-star">*</span></label>
                                        <textarea class="form-control" id="acadp-contact-message" rows="3" placeholder="<?php esc_attr_e( 'Message', 'advanced-classifieds-and-directory-pro' ); ?>..." required></textarea>
                                    </div>
                                    
                                    <div id="acadp-contact-g-recaptcha"></div>
                                    <p id="acadp-contact-message-display">
    
                                    
                                    <button type="submit" class="btn btn-primary"><?php esc_html_e( 'Submit', 'advanced-classifieds-and-directory-pro' ); ?></button>
                                </form> 
                            <?php } ?>
                        </fieldset>
                    <?php endif; ?>
                </div>
            <?php endif; ?>                
        </div>
    
    	<input type="hidden" id="acadp-post-id" value="<?php echo esc_attr( $post->ID ); ?>" />
    </div>
    
    <?php the_acadp_social_sharing_buttons();
Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.
Skip to toolbar