Advertisement
Guest User

Untitled

a guest
Mar 1st, 2016
259
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.78 KB | None | 0 0
  1. function userInvestments() {
  2. // Make the Wordpress database a global:
  3. global $wpdb;
  4. global $current_user;
  5.  
  6. // Get the current user:
  7. get_currentuserinfo();
  8. $userID = $current_user->ID;
  9.  
  10. if( !empty($userID) )
  11. {
  12.     // Run the query to get the Post IDs:
  13.     $results = $wpdb->get_results("SELECT DISTINCT(post_id) FROM wp_postmeta WHERE meta_key = 'investors_attach' AND meta_value LIKE '%\"1\"%'" );
  14.    
  15.     // $results now contains an array as follows:No
  16.     // [
  17.     //    { post_id: 1 },
  18.     //    { post_id: 2 },
  19.     //    ...
  20.     //    { post_id: 19 },
  21.     // ]
  22.    
  23.     // You will need to output the results as follows:
  24.     foreach( $results as $p )
  25.     {
  26.         echo $p['post_id'];
  27.     }
  28. }
  29. }
  30.  
  31. /* add new tab called "mytab" */
  32.  
  33. add_filter('um_account_page_default_tabs_hook', 'my_portfolio_tab_in_um', 100 );
  34. function my_portfolio_tab_in_um( $tabs ) {
  35.   $tabs[800]['myportfolio']['icon'] = 'um-faicon-pencil';
  36.   $tabs[800]['myportfolio']['title'] = 'My Portfolio';
  37.   $tabs[800]['myportfolio']['custom'] = true;
  38.   return $tabs;
  39. }
  40.  
  41. /* make our new tab hookable */
  42.  
  43. add_action('um_account_tab__myportfolio', 'um_account_tab__myportfolio');
  44. function um_account_tab__myportfolio( $info ) {
  45.   global $ultimatemember;
  46.   extract( $info );
  47.  
  48.   $output = $ultimatemember->account->get_tab_output('myportfolio');
  49.   if ( $output ) { echo $output; }
  50. }
  51.  
  52. /* Finally we add some content in the tab */
  53.  
  54. add_filter('um_account_content_hook_myportfolio', 'um_account_content_hook_myportfolio');
  55. function um_account_content_hook_myportfolio( $output ){
  56.   ob_start();
  57.   ?>
  58.    
  59.   <div class="um-field">
  60.     <h2>My Portfolio</h2> Debug
  61.     <?php userInvestments(); ?>
  62.   </div>    
  63.    
  64.   <?php
  65.    
  66.   $output .= ob_get_contents();
  67.   ob_end_clean();
  68.   return $output;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement