• Resolved andykaiser

    (@andykaiser)


    I am using “Post My CF7 Form” version 3.8 with “Contact Form 7” 5.01 and the author seems not to be created correctly with logged in users. It seems that the author is always the one defined in the form instead the loggin in user.

    After some testing I think that the following if is not working: if(isset($cf7_form_data[‘_map_author’]) && is_numeric($cf7_form_data[‘_map_author’])){ is not working.

    Could it be that $cf7_form_data[‘_map_author’] is not passed by contact 7?

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

    (@aurovrata)

    that’s odd.

    It seems that the author is always the one defined in the form instead the loggin in user.

    what do you mean by that? For non-logged in users, the author is by default the admin of the site. When a user logs in their credentials is used.

    This can be overridden using your own author field. Are you mapping one of your form fields to the author post?

    Thread Starter andykaiser

    (@andykaiser)

    Many thanks for your fast reply.

    I’ve been testing this in different scenarios:

    1. Guest User (not logged in) without recipient of the CF7 form

    Seems to work like expected. The author of the post is the Admin User (ID: 1)

    2. Guest user (not logged in) with a recipient of the CF7 form

    Works -> The author of the post is the User with that email (ID: 7)

    3. Logged in User (21) with and without a recipient of the CF7 form

    Not working. The author is the Admin User (in case there is recipient of the CF7 form) or the User with that email (in case no recipient of the CF7 form).

    Note: Following line with the logged in user ID is generated in the html:

    fname = '<input type="hidden" name="_map_author" id="cf7_2_post_user" value="21" />';

    I am not mapping any own form fields to the author post. In this case the order should be logged in user, recipient of the CF7 form and else Admin User (ID:1). The last 2 scenarios seem to work. But not the one with the logged in user.

    I’m not a developer, but I’ve tried to test some code lines in class-cf7-2-post-factory.php and it seems that $cf7_form_data['_map_author'] is not working (line 1172). For example when I define the author after this if with $author = intval($cf7_form_data['_map_author']); the $author ID is not set.

    Hope this helps or I am missing something?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    thank you for the detailed feedback.

    3. Logged in User (21) with and without a recipient of the CF7 form

    Not working. The author is the Admin User

    that’s indeed an error. I am going to run a few test on my server and get back to you.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Hello Andy,

    sorry for the delay in getting back to you on this, been quite busy lately.

    So I took a look on my local machine and its all working just fine form, all 3 scenarios.

    $cf7_form_data['_map_author'] is not working (line 1172)

    this is precisely where the mapped post should be getting its author id from when a logged in user is submitting the form.

    For example when I define the author after this[…]the $author ID is not set.

    the only possible way for your author not to be set is either this line is not executed (because the hidden field _map_author is not submitted, or because a hook is re-setting the author field, which can happend when the filter, cf7_2_post_author_{$post_type} is fired on line 1222.

    Any chance you’re using this filter in your functions.php file?

    Thread Starter andykaiser

    (@andykaiser)

    Many thanks, I will check this asap.

    Thread Starter andykaiser

    (@andykaiser)

    Strange. I’ve tested it in on a new WordPress Site (on the same server) and still have the same issue. No use of the filter in functions.php. Sure I am doing something wrong. I will check it again with more time and send you more information.

    Anyway I’ve found a temporary solution for my site combining another plugin (Dynamic Text Extension). I send the author as a hidden field and map it with Post My CF7 Form. Perhaps not the best, but it works for now.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Strange. I’ve tested it in on a new WordPress Site (on the same server) and still have the same issue. No use of the filter in functions.php. Sure I am doing something wrong. I will check it again with more time and send you more information.

    so there is one more possible error I can think of. The author field is being mapped to the hidden fields of cf7. The cf7 plugin has a set of hidden fields it maintains for tracking its own meta-data. Post My CF7 Form uses this map the hidden author field. I have seen another similar error where a third party plugin was overwriting the hidden fields. Can you please check the hidden field section (it is the child <div> element for the cf7 <form> tag. Check if the _map_author field is correctly being inserted. If u don’t find it, list all the cf7 extensions you are using.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    Hi Andy, any luck resolving your issue? I am assuming you did since I haven’t heard back from your in 4 months. I am flagging this thread as resolved. In case you still have an issue, let me know and we can dive into this again.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Author is not created correctly’ is closed to new replies.