Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function userInvestments() {
- // Make the Wordpress database a global:
- global $wpdb;
- global $current_user;
- // Get the current user:
- get_currentuserinfo();
- $userID = $current_user->ID;
- if( !empty($userID) )
- {
- // Run the query to get the Post IDs:
- $results = $wpdb->get_results("SELECT DISTINCT(post_id) FROM wp_postmeta WHERE meta_key = 'investors_attach' AND meta_value LIKE '%\"1\"%'" );
- // $results now contains an array as follows:No
- // [
- // { post_id: 1 },
- // { post_id: 2 },
- // ...
- // { post_id: 19 },
- // ]
- // You will need to output the results as follows:
- foreach( $results as $p )
- {
- echo $p['post_id'];
- }
- }
- }
- /* add new tab called "mytab" */
- add_filter('um_account_page_default_tabs_hook', 'my_portfolio_tab_in_um', 100 );
- function my_portfolio_tab_in_um( $tabs ) {
- $tabs[800]['myportfolio']['icon'] = 'um-faicon-pencil';
- $tabs[800]['myportfolio']['title'] = 'My Portfolio';
- $tabs[800]['myportfolio']['custom'] = true;
- return $tabs;
- }
- /* make our new tab hookable */
- add_action('um_account_tab__myportfolio', 'um_account_tab__myportfolio');
- function um_account_tab__myportfolio( $info ) {
- global $ultimatemember;
- extract( $info );
- $output = $ultimatemember->account->get_tab_output('myportfolio');
- if ( $output ) { echo $output; }
- }
- /* Finally we add some content in the tab */
- add_filter('um_account_content_hook_myportfolio', 'um_account_content_hook_myportfolio');
- function um_account_content_hook_myportfolio( $output ){
- ob_start();
- ?>
- <div class="um-field">
- <h2>My Portfolio</h2> Debug
- <?php userInvestments(); ?>
- </div>
- <?php
- $output .= ob_get_contents();
- ob_end_clean();
- return $output;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement