Support » Plugin: Post My CF7 Form » add_action hook destroys design

  • Resolved randoms

    (@randoms)


    Hi,
    I have a problem when adding add_action hooks for automatically publishing post and assigning to category.

    This is my code:
    add_action( ‘cf7_2_post_status_post’, ‘publish_new_post’,10,4);
    function publish_new_post($status, $ckf7_key, $submitted_data){
    return ‘publish’;
    }

    add_action(‘cf7_2_post_form_submitted_to_post’, ‘new_post_mapped’,10,4);
    function new_post_mapped($post_id, $cf7_form_data, $cf7form_key, $submitted_files){
    return wp_set_post_categories( $post_id, array( 27 ) );
    }

    add_filter(‘cf7_2_post_filter-post-editor’,’filter_post_editor’,10,4);
    function filter_post_editor($value, $post_id, $form_data) {
    $value = ‘<div class=”project-form-field-content”>
    <div class=”navnerow”><p>‘. $form_data[‘projektleder’] .’, ‘. $form_data[‘afdeling’] .’, ‘. $form_data[‘hospital’] .'</p></div>
    <div class=”beskrivelse”><p>’. $form_data[‘beskrivelse’] . ‘</p></div>
    <div class=”status”><p>’. $form_data[‘status’] . ‘</p></div>
    <div class=”tidspunkt”><p>’. $form_data[‘starttidspunkt’] .’-‘. $form_data[‘sluttidspunkt’] .'</p></div>
    <div/>’;
    return $value;
    }

    My problem is when submitting a post through the form it destroys the columns layout on the page. If I just remove the add_action hooks and manually assign category and publish it, the design is as i should be.

    What am I doing wrong?

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

Viewing 3 replies - 1 through 3 (of 3 total)
  • Okay, it is not only when adding the action hooks. Apparently is is also when just adding it manually. What can I do to not destroy the layout?

    Plugin Author Aurovrata Venet

    (@aurovrata)

    add_action( ‘cf7_2_post_status_post’, ‘publish_new_post’,10,4);
    function publish_new_post($status, $ckf7_key, $submitted_data){
    return ‘publish’;
    }

    there is mistake in this helper code, it should be add_filter and not add_action. This is fixed in v4.1.3

    add_action(‘cf7_2_post_form_submitted_to_post’, ‘new_post_mapped’,10,4);
    function new_post_mapped($post_id, $cf7_form_data, $cf7form_key, $submitted_files){
    return wp_set_post_categories( $post_id, array( 27 ) );
    }

    don’t return anything in an add_action function callback, simply remove the return directive.

    Okay, it is not only when adding the action hooks. Apparently is is also when just adding it manually. What can I do to not destroy the layout?

    I don’t follow. If you have an issue with your column layout in your post table, that means you are customising your table (are you adding a custom column?) and not return properly formatted html. However, this is unrelated to the plugin, as it does not affect the admin table layouts.

    Plugin Author Aurovrata Venet

    (@aurovrata)

    I am assuming you have resolved your issue since I have not heard back from you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.