logo
Ask your WordPress questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$25
Cube Points integration upon completing a form?

I have a buddy press site with cube points installed. This is a two part question/request.

1. I need to add points to a user's account when they submit a form.
2. I have 5 different forms and each one needs to give the user a different amount of points.

I am using contact 7 forms. I don't have much php experience, but have been able to customize quite a bit of the site on my own.

Thanks in advance for the help!

This question has been answered.

tfullen | 07/15/12 at 10:50am Edit


(3) Possible Answers Submitted...

See a chronological view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    07/15/12
    10:56am
    Arnav Joy says:

    can you show the form

    • 07/15/12 11:02am

      tfullen says:



      The site's not live yet, but will be by tonight.

    • 07/15/12 11:05am

      tfullen says:

      http://theglobalgamechangers.com/share-your-story-2/

      Sorry, it appears the link didn't get included...

    • 07/15/12 11:11am

      Arnav Joy says:

      the form can be filled without login/registration , so how to add points
      can you explain full flow as how to include points

    • 07/15/12 11:17am

      tfullen says:

      That's correct. Is there an easy fix to this? I would like to make them only accessible when logged in, but haven't found a solution for that. Is there a plug in or a bit of code that I can put somewhere? Please forgive my lack of knowledge on the programming...

      Ultimately, the flow should be... A user signs up for an account and then has access to all the forms.

      Thanks for the quick response! I'm under the gun and have a ton of design revisions to make. If you can help me with some of the back end work, that would be fantastic!

    • 07/15/12 12:29pm

      tfullen says:

      I found a plug in to restrict certain pages, so that's taken care of.

      Can you help with the original question?

    • 07/15/12 12:59pm

      Arnav Joy says:

      for this work , I have to work in your files..
      so can you please provide me access to the site.

      my email is: thearnavjoy@gmail.com
      skype : arnav.joy

      also can you tell me where are the other forms and how much points to add for each form.

    • 07/15/12 1:45pm

      tfullen says:

      I am backing up the site just in case we have any issues, but in doing so, I realized that none of my custom fields are showing up in the admin database. Do you know of a plug in that will let me view all the data being collected in the wordpress dashboard?

      I'll probably want to skype with you before giving you access to the files, just as a precaution.

      Thanks.

  • avatar
    Last edited:
    07/15/12
    4:29pm

    This answer was downvoted by the top experts.

  • avatar
    Last edited:
    07/16/12
    9:46am
    Gabriel Merovingi says:

    Hi!

    I have made you a custom Cubepoints module that will add points to users when they successfully submit one of your forms.

    Installation:
    1. Copy and Paste the code bellow into a new file and save it as "points_for_cf7form_submissions.php".
    2. Upload the file to wp-content/plugins/cubepoints/modules/
    3. In WordPress find you way to CubePoints Menu > Modules.
    4. Locate the module "Points for Submitting Forms" and click "Activate".
    5. Go to CubePoints > Configure.
    6. Set how many points you want to award for each successful form submission.
    7. Save.

    Minimum Requirements:
    - CubePoints version 3
    - Contact Form 7 version 3.2
    - Both plugins are activated

    Demo:
    http://temp.merovingi.com/
    Username: guest
    Password: guest
    There are two forms on the front page that you can fill out and try. The top form gives 3000 points and the second form gives 1000.

    Code:

    <?php
    /*
    Custom CubePoints Module

    Points for Publishing of Multiple Custom Post Type Module

    Version: 1.0
    */
    define( 'CP_MOD_CF7_POST_TYPE', 'wpcf7_contact_form' );

    // Register our Module
    cp_module_register(

    __( 'Points for Submitting Forms', 'cp' ),
    'formsubmissionpoints',
    '1.0',
    'dbm',
    'http://www.merovingi.com',
    'http://www.merovingi.com',
    __( 'This module awards points when Contact Form 7 forms are submitted successfully.', 'cp' ), 1 );


    // If our module is activated AND if Contact Form 7 is installed and active
    if ( cp_module_activated( 'formsubmissionpoints' ) && function_exists( 'wpcf7' ) ) {

    /** Module Configuration */
    add_action( 'cp_config_form', 'cp_form_submissions_admin_setting' );
    function cp_form_submissions_admin_setting() {

    // Look for all forms
    $cforms7_search_args = array(
    'post_type' => CP_MOD_CF7_POST_TYPE,
    'post_status' => 'any',
    'posts_per_page' => -1,
    'offset' => 0,
    'orderby' => 'ID',
    'order' => 'ASC' );

    // Get points settings
    $cf7_form_points = array();
    $cf7_form_points = get_option( 'cb_form_submission_points' );

    // Header
    echo '
    <br />

    <h3>Contact Form 7 Submissions</h3>
    <table class="form-table">

    <tr valign="top">
    <th scope="row"><label>' . __( 'Form ID' ) . '</label></th>
    <td valign="middle">' . __( 'Points for successful form submissions' ) . '</td>
    </tr>';

    // Our Contact Forms 7 Query
    $cform7_query = new WP_Query( $cforms7_search_args );

    // Found forms
    if ( $cform7_query->have_posts() ) :
    while ( $cform7_query->have_posts() ) : $cform7_query->the_post();

    $cform7_id = get_the_ID();

    echo '
    <tr valign="top">
    <th scope="row">
    <label for="cform7-ID">' . get_the_title() . '</label>
    <input type="hidden" name="cform7[]" value="' . $cform7_id . '" />
    </th>
    <td valign="middle">
    <input type="text" name="cform7-' . $cform7_id . '-points" id="cf7p-' . $cform7_id . '" value="' . $cf7_form_points[$cform7_id] . '" />
    </td>
    </tr>';

    endwhile;

    // If there are no forms
    else :

    echo '
    <tr valign="top">
    <th scope="row"><label>' . __( 'Error' ) . '</label></th>
    <td valign="middle">' . __( 'No Contact Form 7 forms found' ) . '</td>
    </tr>';
    endif;

    // Reset our custom query
    wp_reset_postdata();

    // Footer
    echo '
    </table>';
    }

    /** Save Module Congif */
    add_action( 'cp_config_process', 'cp_form_submissions_save' );
    function cp_form_submissions_save() {

    $cform7_settings = array();

    // Run though all forms and collect the points value
    foreach ( $_POST['cform7'] as $form_id ) {
    $cform7_settings[$form_id] = $_POST['cform7-' . $form_id . '-points'];
    }
    // Remove old points
    delete_option( 'cb_form_submission_points' );
    // Save new points
    update_option( 'cb_form_submission_points', $cform7_settings );
    }

    /** Hook into Contact Form 7 action hook for successful submissions */
    add_action( 'wpcf7_mail_sent', 'cb_form_submission_hook', 5, 1 );
    function cb_form_submission_hook( $cf7_form ) {

    // Grab our points settings
    $cf7_points_settings = array();
    $cf7_points_settings = get_option( 'cb_form_submission_points' );

    // Prep current user
    $cf7_cp_current_user = wp_get_current_user();

    // Run though all settings
    foreach ( $cf7_points_settings as $cf7_form_id => $cf7_form_points ) {
    // If we find the form add points accordingly
    if ( $cf7_form->id == $cf7_form_id ) cp_points( 'formsubmit', $cf7_cp_current_user->ID, $cf7_form_points, $cf7_form->id );
    }

    return $cf7_form;
    }

    /** Adjust the Log. Overwrite custom post type entries. */
    add_action( 'cp_logs_description', 'cp_admin_logs_desc_form7s', 10, 4 );
    function cp_admin_logs_desc_form7s( $type, $uid, $points, $data ) {

    if ( $type != 'formsubmit' ) return;

    // Grab the form details
    $the_cf7_form = get_post( $data );

    _e( 'Points for "' . $the_cf7_form->post_title . '" form submission.' );
    }
    }
    ?>

    attachment image View Attachment

    Previous versions of this answer: 07/16/12 at 9:46am

    • 07/16/12 9:44am

      tfullen says:

      Thanks so much Gabriel. I'll test this out and get back to you.

    • 07/16/12 9:47am

      Gabriel Merovingi says:

      Edit: Adjusted demo address.

    • 07/16/12 11:04am

      tfullen says:

      Gabriel, thank you so much! I implemented the module and it worked flawlessly!

      Please let me know how I get you paid and if I can "vote" for you or do anything else to help your status here.

      Thanks again,
      Tony

    • 07/16/12 11:15am

      Gabriel Merovingi says:

      Glad it worked. You can just vote my answer as the winning one and WP Questions will pay me :) You can always contact me by sending me a message here or by email.

This question has expired.



tfullen voted on this question.



Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.