How to get the values of metadata and display it

I am creating metadata values by using profilemanger 4.7 .....

for example creating field like name , address and etc .....

i want to know how to get the metadata value from the database and i need to display it on to a page ..........

 

sathishkumar


  •     $limit = '20';  // if you want all set it to false, otherwise to a number

        $offset = '0';  // a number or 0

        $users = elgg_get_entities('type' => 'user', 'limit' => $limit, 'offset' => $offset);

        for ($users as $user) {

            $college = $user->collegename;

            echo $college;

        }

    is this right iionly

     

  • iionly its working thanks  changes is



        $limit = '20';  // if you want all set it to false, otherwise to a number

        $offset = '0';  // a number or 0

        $users = elgg_get_entities(array('type' => 'user', 'limit' => $limit, 'offset' => $offset));

        foreach ($users as $user) {

            $field = $user->collegename;

            echo $field;
          

        }

     

  • Yep, I just wanted to post that I made the mistake of "for" instead of "foreach". Good you got it working.

  • thnks u bro .... i need to put a search input box for this college metadata to be searched ........ u got any plugin for that

  • I don't think there's a ready-to-be-used plugin available that would add a search box which gives search results based on specific metadata. I don't know if the normal Elgg search box in a recent Elgg version already gives you all results that match any profile field data even when these profile fields were created with the Profile Manager plugin. The Profile Manager plugin once had the option to search it's profile fields but then this option got removed. But maybe it has been added again in newer versions of the Profile Manager plugin.

    If neither Elgg core nor the Profile Manager plugn support a search based on profile fields of Profile Manager you would have to write the necessary code on your own. The easy approach using the elgg_get_entities_from_metadata() function won't work, because it would only give you these results that match the entered search string exactly.

    What you should take a look at is the code of the bundled search plugin. There are plugin hooks defined for search for different things - users among other things. In the file search_hooks.php the function that searches users is defined. Maybe this function already offers everything that's necessary to search the user's metadata for a given search string - I suspect it does. Then you would need to use this search function by triggering the corresponding plugin hook. The coding would then include an input form, the action that retrieves the users that match the query using the plugin hook and a view that displays the search results.

  • ohh thanks for yur help, i will try ur idea to find a solution