• Hi there,

    I want to pass data from a form to be inserted as tags or custom field while the form is submitted and published as a post.

    Actually I would like to handle this within the template of form-manager – that the function is not called on every published post – what was not working so far.

    Instead I set up an function within my functions.phh to act while a post is published.

    function fm_custom_field($postID) {
    global $_POST;
    $my_keyvalue= $nickname;
    add_post_meta($postID, 'myCustomField', $my_keyvalue, true);
    }
    add_action('publish_post', 'fm_custom_field');

    Doing this everytime a post is published it will create custom field named “myCustomField” but without any key_value in it.

    somebody having an idea?

    thanks for help in advance,
    am

    https://www.ads-software.com/extend/plugins/wordpress-form-manager/

Viewing 10 replies - 1 through 10 (of 10 total)
  • Thread Starter mastermillo

    (@mastermillo)

    some hint would be appreciated!

    Plugin Author hoffcamp

    (@hoffcamp)

    There is a hook, ‘fm_form_submission’ described here, that is called every time a form is submitted successfully.

    Thread Starter mastermillo

    (@mastermillo)

    ok I tried it within the template and functions.php neither works.

    should not it be like that or did I get sometning wrong?

    function my_custom_field($postID) {
    global $_POST;
    
    add_post_meta($postID, 'my_field', 'TESTVALUE that I would like to be filled with a value of a specific nickname' , true);
    }
    add_action('fm_form_submission', 'my_custom_field');

    thanks millo

    Thread Starter mastermillo

    (@mastermillo)

    ok, adding this line in the FormManager template

    add_post_meta(901, 'custom_field_name', $custom_field_value, true);

    will create the custom field and put the right custom_field_value in that specific field.
    But only if the real postID is specified.

    My question now, how can I retrieve the right postID from the form submission within the template?
    I tried several ways like the_ID() or get_post_ID() but all was not working yet.
    thanks for any idea, millo

    Thread Starter mastermillo

    (@mastermillo)

    thanks, got it working
    the used postID I can get like this within the template and my code looks like this:

    $my_custom_field_value_var = fm_summary_get_item_value('nickname');
    $my_get_lastID = wp_get_recent_posts('1');
    $my_thePostID = $my_get_lastID['0']['ID'];
    add_post_meta($my_thePostID, 'custom_field_name', $my_custom_field_value_var, true);

    hi millo,

    Great that you manage to get it working. I am also looking for a similar solution but i am not an expert like you. Could you please share the solution in a “for dummies” form? I tried inserting the above piece of code in the fm-form-default.php file and replaced “nickname” with my field nick name. Should i modify anything in functions.php?`Where can i find this file? Thanks in advance.

    Thread Starter mastermillo

    (@mastermillo)

    Hi jrWP,
    I’d like to try, even it is already for dummies like us ??

    1. build your own template by saving the fm-summary-multi.php with your individual name and choose it from the dropdown (data summary) in the ADVANCED TAB where you can edit the form you want, i.e. yourdomain.com/wp-admin/admin.php?page=fm-edit-form&sec=advanced&id=1. (that is a better way working with it) – I think you just took the wrong template, as fm-form-default.php just displays the form where you can enter your stuff!!!

    2. within the functions.php (to be found in your themes folder or child theme folder -> better make yourself a child theme) you do not need to modify anything.

    3. what do you want to do actually? But I think with step 1 it should be solved… ??

    success, millo

    i modified the helpers.php file to include ‘tags_input’ => fm_summary_get_item_value(‘nickname’) .This worked perfectly and i could filter my posts by clicking on the tag name in any post.

    code below and above the tag_input looks like this:
    ‘post_author’ => 1,
    ‘tags_input’ => fm_summary_get_item_value(‘location’),
    ‘post_category’ => array($formInfo[‘publish_post_category’])
    );

    Thread Starter mastermillo

    (@mastermillo)

    off topic ??? I cannot follow. helpers.php should not be edited I guess.
    Anyway if it works what you want to do, but if you update the plugin your work might be gone….

    Hey Milo does this still work for you? Did you put the code in the template.php in the main folder and did this actually create field that shows up in the admin page for the post? If so what exactly did you place in there because I was trying to figure it out and was totally lost which drives me crazy because this plugin does everything right except the most important thing.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘[Plugin: WordPress Form Manager] adding tags and custom field’ is closed to new replies.