• Resolved erishv

    (@icode794)


    Hi,

    First of all, thank you for the plugin, I was trying to figure out how to save the CF7 data as posts, and found your wonderful plugin. Thank you so much!

    But I have some few questions,
    How can I make the logged in user as the author of the post? Can you help me with the options to check? or the codes to add on the functions.php?

    Also, there are some points that you need to fix to make this plugin better.
    1. Editing the mapped contact forms breaks their title
    2. Rather than generating contact form names with dash (-) on the functions.php, please use underscore (_)

    Will be waiting for your feedback,

    Thank you so much!

    The page I need help with: [log in to see the link]

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Aurovrata Venet

    (@aurovrata)

    thank you for the plugin, I was trying to figure out how to save the CF7 data as posts, and found your wonderful plugin

    please do leave a constructive review, open-source development has few rewards, but a big part of this is to see our code flourish, and reviews help others to try it out.

    How can I make the logged in user as the author of the post?

    this is already the default behaviour.

    Editing the mapped contact forms breaks their title

    can you be more specific on this. Which title are you talking about?

    Rather than generating contact form names with dash (-) on the functions.php, please use underscore (_)

    again, not sure what you are referring to. If by form-name you mean the unique form key, then this the WP std which is followed. The unique key is simply the cf7 post slug, which is created from the title. Replace you spaces with underscores in your title and your key will have underscores.

    Thread Starter erishv

    (@icode794)

    Hi Aurovrata Venet,

    Thank you for the time to reply on this thread. I appreciate it.
    Alright, I will try to construct it the best that I can.

    1. Form UI is the default of CF7 but I added a hidden field with a value of “casting-calls” to use as the category slug. (CF7 Form Screenshot)

    2. I mapped the form to an existing post type (post) (CF7 Mapping Screenshot)

    3. After submitting the form, the contents are being mapped to existing post, but not mapping the taxonomy (category) which is set as a hidden field, and not mapping the author which is a logged in user that submitted the post (All Posts Screenshot)

    4. I am trying to map the taxonomy (category) via a hook filter, it is not showing the hidden field, not able to select it as the taxonomy (Taxonomy Mapping, snippet code).

    Please help. Thank you

    Thread Starter erishv

    (@icode794)

    I am hoping to do the following:
    1. Map the submitted form to an existing post type, post – which is done
    2. Map the submitted form to a taxonomy, category not a CPT.
    3. Map the logged in user as the author to be able to edit the submitted form.

    Here is the link how it is now: https://prntscr.com/li4oau
    2. Taxonomy is being set as Uncategorized, default by WP
    3. Author is set to the administrator, even if the user logged in before submitting the form.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I don’t understand what you are trying to achieve.

    You have a contact form (with name/email/message) and a hidden field. What do you want to do with the category? Do you want to set a category term depending on the email or name values?

    I am trying to map the taxonomy (category) via a hook filter,

    ok, well the concept of a hook is that you need to hook it with a add_filter declaration, and use a custom function to return the value you want to save in the category. Furthermore, you have declared a new taxonomy, so the plugin will create that taxonomy and associate it the post post_type …. not sure this is what you are actually expecting.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    just seeing your new msg,

    I am hoping to do the following:
    1. Map the submitted form to an existing post type, post – which is done

    good

    2. Map the submitted form to a taxonomy, category not a CPT.

    that’s what I thought, however it is still not clear how. Please see my previous msg. Are you wanting to display a dropdown list with your existing category terms and allow a user to select a value? Or do you want to set the category term systemically when a form is submitted, irrespective of the submitted values?

    3. Map the logged in user as the author to be able to edit the submitted form.

    this is the default behaviour.

    2. Taxonomy is being set as Uncategorized, default by WP

    sure because you’re not setting it, nor have any fields mapped to the category taxonomy.

    3. Author is set to the administrator, even if the user logged in before submitting the form.

    that’s odd, it shouldn’t be

    Plugin Author Aurovrata Venet

    (@aurovrata)

    3. Author is set to the administrator, even if the user logged in before submitting the form.

    ok, I just realised it does not work as expected … just releaseing a fix along with some updates for WP 5.

    Thread Starter erishv

    (@icode794)

    Hi Aurovrata, Sorry for the late response.
    Been busy with other projects and just came to thank you for the updates on the plugin and for developing the features we need. Thank you so much,

    In response to

    that’s what I thought, however it is still not clear how. Please see my previous msg. Are you wanting to display a dropdown list with your existing category terms and allow a user to select a value? Or do you want to set the category term systemically when a form is submitted, irrespective of the submitted values?

    Yes, I am trying to save map the posts to a category named “Testing”, so every post that is being submitted via Contact Form 7, will be posted on the default taxonomy Post, and a category of Testing.

    Reference:
    https://prntscr.com/lqe53c

    How can I achieve it?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Sorry for the late response.

    no issues.

    thank you for the updates on the plugin and for developing the features we need. Thank you so much

    do leave a review, I would accept that as fair change ??

    Yes, I am trying to save map the posts to a category named “Testing”, so every post that is being submitted via Contact Form 7, will be posted on the default taxonomy Post, and a category of Testing.

    you need to use the action that is fired after the form is saved to your post. The post Id is passed along and you can therefore programmatically assign the term to your saved post. The action is documented in the actions & filter metabox (screenshot) #16 in your form mapping edit page.

    Thread Starter erishv

    (@icode794)

    Hi Aurovrata,

    you need to use the action that is fired after the form is saved to your post. The post Id is passed along and you can therefore programmatically assign the term to your saved post. The action is documented in the actions & filter metabox (screenshot) #16 in your form mapping edit page.

    Alright, I think this is the action I need

    <?php
    add_action('cf7_2_post_form_submitted_to_post', 'new_post_mapped',10,3);
    /**
    * Function to take further action once form has been submitted and saved as a post.  Note this action is only fired for submission which has been submitted as opposed to saved as drafts.
    * @param string $post_id new post ID to which submission was saved.
    * @param array $cf7_form_data complete set of data submitted in the form as an array of field-name=>value pairs.
    * @param string $cf7form_key unique key to identify your form.
    */
    function new_post_mapped($post_id, $cf7_form_data, $cf7form_key){
       // do something
    }

    On the do something, what are the parameters or values I should put in to save the post to a category?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    On the do something, what are the parameters or values I should put in to save the post to a category?

    that std WP functionality that you can find the codex.
    You can also seek help on stackoverflow or WP forums.

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Login User as Post Author’ is closed to new replies.