Forum Replies Created

Viewing 15 replies - 1 through 15 (of 16 total)
  • Thread Starter mackans

    (@mackans)

    Yeah I know that, you have told me before 🙂

    Thread Starter mackans

    (@mackans)

    Ok. Earlier when I said the table showed up perfectly, that was obviously not true. I didn’t know I was supposed to get the search bar and some decoration as well 🙂

    Not sure if I can verify your hypothesis. The HTML looks identical if I execute the shortcode using ACF (as I have shown above) or just putting it in a post. The script is there in the bottom line. See this screenshot.

    Script load ht

    Thank you for taking your time!

    • This reply was modified 9 years, 1 month ago by mackans.
    Thread Starter mackans

    (@mackans)

    Hi again Michael
    Any ideas on this? Is there something wrong with my version of the plugin? If you try the same shortcode does it work for you? Are the cells editable? Do you think it has something to do with my custom theme? Is there something missing in my custom theme? Anyone else had this problem before?

    /Marcus

    Thread Starter mackans

    (@mackans)

    Sure, I’ll try to explain!

    Step 1.
    Ht 1
    In the Advanced Custom Fields panel, I create a new field group with one field. I name the field, assign it a unique field name registration-shortcode, and choose the field type. In this case I choose a WYSIWYG-field. I also choose on which page/pages I wan’t this field group to show up so that I can edit the content in the WYSIWYG-field later.

    Step 2.
    Ht 2
    In order to make the content I put in the WYSIWYG-field to display on front-end, I add this code to my HTML code <?php the_field('registration-shortcode'); ?>. Note the identical unique field names.

    Step 3.
    Ht 3
    Next I go to the page that I choose the field group to show up on. And here’s my recently created WYSIWYG-field ready to be edited. I add the shortcode [cfdb-datatable form="Anmälan LÃ¥nga" edit="cells" filter="email=$user_email"]

    Step 4.
    Ht 4
    The content in the WYSIWYG-field will show up on front-end perfectly!

    But the datatable is not editable.

    • This reply was modified 9 years, 1 month ago by mackans.
    Thread Starter mackans

    (@mackans)

    I’m using Advanced Custom Fields for most of my texts on the web. Didn’t know that I could put the shortcode inside a wysiwyg field. I just did that and the datatable shows up just fine. BUT, it’s still not editable!!

    What am I doing wrong? As i said before I have everything installed and activated. The editor extension is working fine in the admin panel.

    Marcus

    Thread Starter mackans

    (@mackans)

    I’m more confused than you are for sure. When I’m just putting the shortcode directly in the HTML code this is what I get on my webpage:

    Shortcode harnotrail.se

    I have many other shortcodes on the webpage and they work great, and I have put all of them in a “do_shortcode” call.

    I’m using a custom theme and custom templates. Is that the reason why it’s not working to just put the shortcode directly into the HTML code?

    /Marcus

    Thread Starter mackans

    (@mackans)

    Sorry, but I don’t really understand. If I just put

    [cfdb-datatable form="Form Name" edit="cells" filter="email=$user_email"]

    in the HTML code, the exact same will be shown on the web…

    What about something like this, is this a good start? Can you help me finish it if I’m on the right track?

    add_shortcode('editregistration', 'editregistration_callback');
    function editregistration_callback ('Form Name', array('edit' => 'cells', "filter" => "email=$user_email")) {
        
    }
    • This reply was modified 9 years, 2 months ago by mackans.
    • This reply was modified 9 years, 2 months ago by bdbrown.
    Thread Starter mackans

    (@mackans)

    Hmm okay. Is there another way to call a shortcode instead of using do_shortcode?

    Marcus

    Thread Starter mackans

    (@mackans)

    I have now tried with the actual form name instead of * but it doesn’t work.

    I tried the most simple shortcode like this:

    <?php echo do_shortcode('[cfdb-datatable form="Form Name" edit="cells"]'); ?>

    and that gives me the whole datatable with around 300 submissions but none of the cells are editable.

    Thread Starter mackans

    (@mackans)

    Currently I have these two plugins installed:

    Contact Form DB
    Contact Form DB Editor

    Am I missing one more plugin?

    Thread Starter mackans

    (@mackans)

    Thread Starter mackans

    (@mackans)

    Thank you! It works!

    Thread Starter mackans

    (@mackans)

    EDIT: I have to clarify my first post as I’ve noticed it’s not understandable at all…

    This is what I mean: The function above counts all submissions based on the ‘submit_time’ column. I have another column namned ‘registrationcode’. Out of 100 submissions, only 5 submissions has a value in this column. I want to exclude those 5 rows from the count function (or any row that has a value in that column). In other words, I only want to include the rows that has an empty value in the column ‘registrationcode’.

    Thanks

    Thread Starter mackans

    (@mackans)

    Hi again

    Your code above works great! I have another question now. How can I make the function to exclude rows that has a value in a certain column?

    For example, in the form I have a field that is optional to fill in. If the field is left blank I don’t want to include this submission (the row in the database) in the count function.

    • This reply was modified 9 years, 2 months ago by mackans.

    Hi
    Install the plugin Shortcodes, Actions and Filters. Add a new function and add this in the code editor:

    function is_already_submitted($formName, $fieldName, $fieldValue) {
        require_once(ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CFDBFormIterator.php');
        $exp = new CFDBFormIterator();
        $atts = array();
        $atts['show'] = $fieldName;
        $atts['filter'] = "$fieldName=$fieldValue";
        $atts['unbuffered'] = 'true';
        $exp->export($formName, $atts);
        $found = false;
        while ($row = $exp->nextRow()) {
            $found = true;
        }
        return $found;
    }
    
    function my_validate_email($result, $tag) {
        $formName = 'NAME OF YOUR FORM'; // Change to name of the form containing this field
        $fieldName = 'NAME OF YOUR E-MAIL FIELD'; // Change to your form's unique field name
        $errorMessage = 'ERROR MESSAGE HERE'; // Change to your error message
        $name = $tag['name'];
        if ($name == $fieldName) {
            if (is_already_submitted($formName, $fieldName, $_POST[$name])) {
                $result->invalidate($tag, $errorMessage);
    		}
        }
        return $result;
    }
    
    add_filter('wpcf7_validate_email*', 'my_validate_email', 10, 2);

    Remove the * from the bottom line if the field is NOT a required field. Otherwise leave it. This works for me, that’s all I can say.

Viewing 15 replies - 1 through 15 (of 16 total)