Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I use gravity forms and wp-favorites plugin (helps users select their favorite posts).

I am trying to auto-populate gravity form with the following snippet. It works pretty well but it shows only the first item in the list.

How can I get all items in the array?

add_filter("gform_field_value_circle", "populate_square");
function populate_square ($value) {
    $favs = wpfp_get_users_favorites();
    foreach ($favs as $fav){
        $list = get_the_title($fav);
    return $list;

This snippet shows me the title of the first selected post only. I would like to get a list of all the selected posts, how do I acheive that ?

FYI, I am trying to make use of the HOOK provided by gravity forms. You can see the code here.

Pleae let me know if I need to be more clear.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

If it is a dropdown and you want to populate it with options may be use this filter

add_filter("gform_predefined_choices", "add_predefined_choice");
function add_predefined_choice($choices){
   $choices["My New Choice"] = array("Choice 1", "Choice 2", "Choice 3");
   return $choices;


gform_field_value_selection filter is for default value.

Give a look here http://www.gravityhelp.com/documentation/page/Developer_Docs

See if this works..

  add_filter("gform_field_value_selection", "populate_selection");
    function populate_selection ($value) {
        $favs = wpfp_get_users_favorites();
        $list = array();
        foreach ($favs as $fav){
        $list[] = get_the_title($fav);
        return $list;

share|improve this answer
It returns a text 'Array'. Any thoughts ? Thank you. –  gurung Jan 3 '13 at 6:11
@gurung have edited my answer.. –  Rajeev Vyas Jan 3 '13 at 6:21
No I did not edit your answer. and No it is not a drop down. But as indicated I have done a minor corrections in the parameter name and the function name, just to make sure they are not default values. I have also given a link to gravity forms to see the hook in action. Thank you for trying. –  gurung Jan 3 '13 at 6:43
oops.. i thought you meant i edited your answer. Cn you help me further please. thnks –  gurung Jan 3 '13 at 10:11
@gurung What kind of field it is? for ex. List field or some thing else? –  Rajeev Vyas Jan 3 '13 at 11:10

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.