My Account in Supreme Directory

This topic contains 10 replies, has 3 voices, and was last updated by  Giri 6 years, 9 months ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #390098

    Roman
    Buyer
    Post count: 232

    Hi,

    Is there a hook to add “My Listings” and “My Favorites” to “My Account” menu in the navigation bar in Supreme?

    Thank you.

    #390103

    Giri
    Expired Member
    Post count: 3155

    Hopefully you are using buddypress.

    If thats the case try this code.

    
    
    add_filter('geodir_dashboard_links', 'dt_geodir_dashboard_links_custom');
    function dt_geodir_dashboard_links_custom($dashboard_link) {
    	if ( class_exists( 'BuddyPress' ) ) {
    		$user_link = bp_get_loggedin_user_link();
    		$dashboard_link .= '<li>';
    		$dashboard_link .= '<i class="fa fa-user"></i>';
    		$dashboard_link .= '<a href="'.$user_link.'listings/'.'">';
    		$dashboard_link .= __('My Listings', 'gdbuddypress');
    		$dashboard_link .= '</a>';
    		$dashboard_link .= '</li>';
    
    		$dashboard_link .= '<li>';
    		$dashboard_link .= '<i class="fa fa-cog"></i>';
    		$dashboard_link .= '<a href="'.$user_link.'favorites/'.'">';
    		$dashboard_link .= __('My Favorites', 'gdbuddypress');
    		$dashboard_link .= '</a>';
    		$dashboard_link .= '</li>';
    	}
    	return $dashboard_link;
    }
    #390108

    Roman
    Buyer
    Post count: 232

    Hi Giri, no I don’t use it, is there a way to do it without BP?

    #390113

    Roman
    Buyer
    Post count: 232

    I’ve found something in this thread here https://wpgeodirectory.com/support/topic/my-account-functionality/

    
    
    add_action('sd_my_account_logged_in_extras', 'sd_my_account_logged_in_extras');
    function sd_my_account_logged_in_extras() {
       ?>
    <ul class="sd-my-account-dd-menu-group sd-my-account-dd-menu-bp-group">
                            <li class="sd-my-account-dd-menu-link">
                                <a href="#">
                                    <i class="fa fa-user"></i> Link1
                                </a>
                            </li>
                            <li class="sd-my-account-dd-menu-link">
                                <a href="#">
                                    <i class="fa fa-user"></i> Link2
                                </a>
                            </li>
                        </ul>
      <?php
    }

    It’s a good option to add a link, but not exactly “My Favourites” or “My listings” since every user has his different urls for this.

    #390114

    Roman
    Buyer
    Post count: 232

    Maybe there is a way to modify it so that it works for Favorites and Listings as well?

    #390118

    Giri
    Expired Member
    Post count: 3155

    Try this code.

    
    
    add_filter('geodir_dashboard_links', 'dt_geodir_dashboard_links_custom');
    function dt_geodir_dashboard_links_custom($dashboard_link) {
    	if (!is_user_logged_in()) {
    		return $dashboard_link;
    	}
    	$post_types = geodir_get_posttypes('object');
    
    	$user_id = get_current_user_id();
    	$author_link = get_author_posts_url($user_id);
    	$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
    	
    	$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
    	$user_listing = geodir_user_post_listing_count($user_id);
    	$my_listings_link = false;
    
    	$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
    	$user_favourite = geodir_user_favourite_listing_count($user_id);
    	$my_favorites_link = false;
    	
    	foreach ($post_types as $key => $postobj) {
    		if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
    			if (!$my_listings_link) {
    				$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
    
    				$dashboard_link .= '<li>';
    				$dashboard_link .= '<i class="fa fa-user"></i>';
    				$dashboard_link .= '<a href="'.$listing_link.'">';
    				$dashboard_link .= __('My Listings', 'gdbuddypress');
    				$dashboard_link .= '</a>';
    				$dashboard_link .= '</li>';
    
    				$my_listings_link = true;
    			}
    		}
    	}
    
    	foreach ($post_types as $key => $postobj) {
    		if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
    			if (!$my_favorites_link) {
    				$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
    				
    				$dashboard_link .= '<li>';
    				$dashboard_link .= '<i class="fa fa-user"></i>';
    				$dashboard_link .= '<a href="'.$post_type_link.'">';
    				$dashboard_link .= __('My Favorites', 'gdbuddypress');
    				$dashboard_link .= '</a>';
    				$dashboard_link .= '</li>';
    
    				$my_favorites_link = true;
    			}
    		}
    	}
    	
    	
    	return $dashboard_link;
    }
    #390150

    Roman
    Buyer
    Post count: 232

    This snippet ads links to the dashboard, but I rather meant the Supreme directory specific “My Account” area, please see the attached screenshot. It would be most intuitive to have those links up there rather than on “my dashboard”

    #390155

    Paolo
    Site Admin
    Post count: 31206

    Hi Roman,

    support is exclusively for members and this is even beyond support.

    Thanks

    #390156

    Giri
    Expired Member
    Post count: 3155

    Hi Roman,

    The above snippets and current snippet I provided is specifically created for you and that takes time.

    Please consider renewing your membership if you are planning to seek our help in the future.

    Thanks

    
    
    add_action('sd_my_account_logged_in_extras', 'dt_geodir_dashboard_links_custom');
    function dt_geodir_dashboard_links_custom() {
    	if (!is_user_logged_in()) {
    		return;
    	}
    
    	$dashboard_link = '';
    	$post_types = geodir_get_posttypes('object');
    
    	$user_id = get_current_user_id();
    	$author_link = get_author_posts_url($user_id);
    	$author_link = geodir_getlink($author_link, array('geodir_dashbord' => 'true'), false);
    
    	$show_listing_link_user_dashboard = get_option('geodir_listing_link_user_dashboard');
    	$user_listing = geodir_user_post_listing_count($user_id);
    	$my_listings_link = false;
    
    	$show_favorite_link_user_dashboard = get_option('geodir_favorite_link_user_dashboard');
    	$user_favourite = geodir_user_favourite_listing_count($user_id);
    	$my_favorites_link = false;
    
    	foreach ($post_types as $key => $postobj) {
    		if (in_array($key, $show_listing_link_user_dashboard) && array_key_exists($key, $user_listing)) {
    			if (!$my_listings_link) {
    				$listing_link = geodir_getlink($author_link, array('stype' => $key), false);
    
    				$dashboard_link .= '<li>';
    				$dashboard_link .= '<i class="fa fa-user"></i>';
    				$dashboard_link .= '<a href="'.$listing_link.'">';
    				$dashboard_link .= __('My Listings', 'gdbuddypress');
    				$dashboard_link .= '</a>';
    				$dashboard_link .= '</li>';
    
    				$my_listings_link = true;
    			}
    		}
    	}
    
    	foreach ($post_types as $key => $postobj) {
    		if (in_array($key, $show_favorite_link_user_dashboard) && array_key_exists($key, $user_favourite)) {
    			if (!$my_favorites_link) {
    				$post_type_link = geodir_getlink($author_link, array('stype' => $key, 'list' => 'favourite'), false);
    
    				$dashboard_link .= '<li>';
    				$dashboard_link .= '<i class="fa fa-user"></i>';
    				$dashboard_link .= '<a href="'.$post_type_link.'">';
    				$dashboard_link .= __('My Favorites', 'gdbuddypress');
    				$dashboard_link .= '</a>';
    				$dashboard_link .= '</li>';
    
    				$my_favorites_link = true;
    			}
    		}
    	}
    
    	echo $dashboard_link;
    }
    #390175

    Roman
    Buyer
    Post count: 232

    I will, sorry about that guys and thank you.

    #390232

    Giri
    Expired Member
    Post count: 3155

    You are welcome.

Viewing 11 posts - 1 through 11 (of 11 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket