• Resolved Nugerama

    (@nugerama)


    I’m looking for a solution to add a number of points (using MyCred plugin) to a user’s profile when they submit a form. More specifically, I’m hoping to use Toro Forms to create surveys for users to fill out and issue the points as a reward for submitting a response.

    How might I hook into that form action to execute the mycred_add() function, passing the user’s ID and thus crediting their account?

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Nugerama

    (@nugerama)

    Okay, I’m now using the Form Action API code snippet (here: https://torro-forms.com/api/extending/form-actions/) which extends the Torro_Form_Action class. I’m a little out of my depth here, can anyone explain why I get:

    Fatal error: Call to protected Torro_Form_Action::__construct() from context ‘Torro_Manager’ in /Applications/MAMP/htdocs/sandbox/wp-content/plugins/torro-forms/core/managers/class-manager.php on line 66

    Plugin Author Sven Wagener

    (@mahype)

    Hi,

    if you want to use MyCred, the eaysiest way to do that is to use the shortcodes of MyCred.

    Just put somethong like

    [mycred_give amount=”10″ log=”He answered the Form” ref=”bonus_points”]

    to Redirections > Textmessage in the form. I think thats the easiest way to implement it. We don’t have an extra plugin for that yet. But we are thinking about to create an extension for that.

    I will check the error and have already added an issue for that on Github:
    https://github.com/awsmug/torro-forms/issues/330

    This problem will be solved the next days in the develope version and will come with 1.0.0 beta 8.

    Thank you for reporting! ??

    Greetings,

    Sven

    Thread Starter Nugerama

    (@nugerama)

    Thanks for your response, Sven. On further investigation of the working form actions inside the plugin I found that I could get mine working by including a couple of extra functions, namely:

    private static $instance = null;

    and

    public static function instance() {
    	if ( null === self::$instance ) {
    		self::$instance = new self();
    	}
    	return self::$instance;
    }

    With the hooked action in place I’ve managed to add a tab in the admin which let’s the user allocate points to a form and then runs the mycred_add function on submission. I spotted a couple of other typos in the example in your docs too: a missing semi-colon on line 33 and the last line tries to register the main class instead of the new one, torro()->actions()->register( 'Torro_Form_Action' ); should be torro()->actions()->register( 'My_Action' );.

    Great plugin. This has so far proved the perfect solution to my client’s requirement for a survey builder.

    Thanks again

    Plugin Author Sven Wagener

    (@mahype)

    That makes me happy! ??

    And thank you for your investigation. I will check and fix this today.

    If you want to support us, I would be very grateful if you would rate the plugin!

    Greetings,

    Sven

    Thread Starter Nugerama

    (@nugerama)

    Of course, done.

    Plugin Author Sven Wagener

    (@mahype)

    Hi,

    I have fixed the problem, so that you do not need your $instance variable and function anymore. The cunstructor had to be public. I have changed this for the upcoming version 1.0.0 beta 8.

    https://github.com/awsmug/torro-forms/issues/330

    You can get it, if you download the develop version from Github.

    https://github.com/awsmug/torro-forms/tree/develop

    Also I have fixed my errors in the documentation.

    Greetings,

    Sven

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Execute Function on Form Submission’ is closed to new replies.