• Resolved bkseen

    (@bkseen)


    Hi there,

    I’ve read lot of forum but I didn’t find the solution to my problem.

    I have a form with a “Save As Post Type” : When this one is submitted it create my object “Team”.

    I would like to have get the ID of this created team to add that one to the user (as a meta-data) with user registration. If the user register his team it’s the normal way is he had to be a part of this one, but nowadays I have to do that manually.
    I read a bit about a command after the submit of the form but I didn’t really understand how to get the id of my object. I Tried a bit with the User Registration to create a Meta-Data but didn’t work.

    Thanks in advance for the help, feel free to ask more details!

    Cheers

    https://www.ads-software.com/plugins/gravity-forms-custom-post-types/

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter bkseen

    (@bkseen)

    Up.. no one to answer around here? I think my question is not so hard ??

    Cheers

    Plugin Author Dave from Gravity Wiz

    (@spivurno)

    Hi bkseen, something like this in your functions.php should do the trick. Update “my_custom_key” to whatever you want the meta key to be.

    add_action( 'gform_user_registered', function( $user_id, $feed, $entry ) {
    	add_user_meta( $user_id, 'my_custom_key', $entry['post_id'] );
    }, 10, 3 );
    Thread Starter bkseen

    (@bkseen)

    Hi David, I tried you solution..and it doesn’t work.

    I’ve replaced “my_custom_key” by the meta added with Custom Field, that my team_id.

    my code at the total end of functions.php :

    add_action( 'gform_user_registered', function( $user_id, $feed, $entry ) {
    	add_user_meta( $user_id, 'team_id', $entry['post_id'] );
    }, 10, 3 );

    I tried to replace post_id by ’18’ (my post ID) but nothing happen.

    By the way I’ve seen something like that: here , is it not the solution?

    Please help me, it’s profesionnal and really important!

    Cheers,

    bkseen

    Thread Starter bkseen

    (@bkseen)

    I don’t know if it helps, but the type of my Custom Field is a : Post Object

    Plugin Author Dave from Gravity Wiz

    (@spivurno)

    Hi bkseen, if that doesn’t work, you’ll want to contact Gravity Forms support. The example was pulled from their documentation (I did change the function from update_user_meta to add_user_meta):

    https://www.gravityhelp.com/documentation/article/gform_user_registered/#examples

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Update user meta after submit Post Type’ is closed to new replies.