• Hi,

    Apologies if this isn’t the right place for my question, I was after an overview of the method, hence trying here, but please advise if I need to move/delete this. Thanks.

    I have built something that works, so I am not fixing an issue as such, but would like a community view as to whether it is a decent solution.

    Desired feature: I am running an e-learning site, I would like users to be to click ‘mark complete’ on each relevant post.

    I have been using Sensei LMS, but find it too clunky for some lighter tasks.
    Wpcomplete seems not to be supported anymore
    https://www.ads-software.com/plugins/wpcomplete/
    Similarly favorites:
    https://en-gb.www.ads-software.com/plugins/favorites/

    As I don’t want to run into issues in the future switching systems, and users losing their progress, I want to get something I can adapt and continue.

    Homemade solution.
    Ninja forms + custom SQL

    I created a ninja contact form which invisibly collects user_id and post_id on the submission.
    I append this form to all posts in relevant category.
    On each page run a shortcode to display results of custom sql looking for current post_id in submissions: returns ‘to do’ for zero rows and ‘done’ for >0 rows.

    add_shortcode('done_shortcode', 'done_shortcode');
    function done_shortcode( $atts ) {
    ? ? global $wpdb;
    $user_ID = get_current_user_id(); 
    $current_post_id = get_the_ID();
    $results = $wpdb->get_results("
    SELECT 
    case when count(*) = 0 then 'To Do' else 'Done ?' end as completion_state
    FROM wp_posts p 
    where p.post_type='nf_sub'
    and p.id in (select post_id from wp_postmeta where meta_key='_form_id' and meta_value='2')
    and post_author = $user_ID ?
    and (select meta_value from wp_postmeta where post_id=p.id and meta_key='_field_296')=$current_post_id
    order by post_date desc
    ;
    ? ? ");
    
    ? ? // Start buffering
    ? ? ob_start();
    
    ? ? // Loop 
    ? ? foreach( $results as $result ){
    	echo '<em>' . $result->completion_state . '</em>';
    ? ? }
    
    ? ? // Return output
    ? ? return ob_get_clean();
    }

    Am I crazy? Or is this a feasible solution if it works ( it does). Essentially a contact form adds a line to the database and sends an email, which is exactly all I need. or am I misusing it? Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator bcworkz

    (@bcworkz)

    If you are using the basic Ninja Forms with no add-ons, you’re using GPL licensed software on your own website. It’s difficult to imagine how anyone could consider what you’ve done as “abuse”. If you use any add-ons to manage this, any abuse would depend upon the add-on’s licensing terms. But since the data you collect resides on your site’s server, it’s difficult for me to see any form of abuse.

    Keeping a log of user IDs could possibly run afoul of any applicable privacy laws such a GDPR. That would be a legal question which we cannot address in these forums. If you have any doubts in this regard we recommend seeking the advice of qualified legal counsel.

    Thread Starter jvsouthwood

    (@jvsouthwood)

    Hi, thanks so much for considering it. Apologies, I must not have stated it well enough, but I was meaning more misuse from a technical perspective. I.e. is this a bad hack, or else a reasonable tech solution to my needs? The users are all my registered members and I consider GDPR elsewhere. Thank you!

    • This reply was modified 8 months, 1 week ago by jvsouthwood.
    Moderator bcworkz

    (@bcworkz)

    As long as you’re not modifying someone else’s code and your solution works as desired, I would never consider it misuse. You’ve apparently developed your own custom shortcode and otherwise used Ninja Forms as intended. I would say this is not misuse. Not only that, but adaptive use of existing resource to save development time is clever and desirable.

    The only other consideration is if your solution was so inefficient that it drags down the performance of your site, it would be quite undesirable. Still not necessarily “misuse” per se, but undesirable.

    Thread Starter jvsouthwood

    (@jvsouthwood)

    Thanks for the reassurance. I am using these exiting tools mainly for performance reasons – as an alternative to installing a new plugin which could bring it down. And, as I coded it, I can future-proof to some extent as I can export/import at will.

    If someone were to highlight that this could/should be done better using custom fields or some other means, I would be interested, otherwise I’ll go with it – just running a sanity check.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Using contact form for logging – misuse or not?’ is closed to new replies.