This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
I am currently trying to create a one to many relationship form that captures both the current page the user is on (done) and link it to a post that is automatically created when a user registers.
This post is the only post that the user will ever author on the site and is used to link completed modules to her profile. My issue currently is that I would like the CRED relationship form to auto-populate the relationship field with the automatically created post authored by my currently logged in user.
the post created as of now is a custom post type called 'completed-modules' and the automatically generated post is always titled the user_id of the registrant. IE. "15"
so my first thought was to write out a shortcode that wrote the shortcode for the CRED form:
add_shortcode( 'my_user_ID', 'user_id_callback' );
function user_id_callback( $atts, $content = null ) {
// (int) The current user's ID, or 0 if no user is logged in.
return do_shortcode(
'[cred-relationship-form form="completed-module-form" parent_item="$current" child_item="' . get_current_user_id() . '"]'
);
}
So this does do what I intended it to do, except the cred form doesn't actually work, which I'm not totally surprised by but would love some insight into how to get this to work properly.
The Slug for the dynamically created posts does not really matter at all. These only exist to have a relationship formed between them as the user completes courses on the site.
Minesh is on holiday today which is why I'm following up on this ticket.
Can you update your custom shortcode slightly to see if it makes any difference?
add_shortcode( 'my_user_ID', 'user_id_callback' );
function user_id_callback( $atts, $content = null ) {
// (int) The current user's ID, or 0 if no user is logged in.
ob_start();
echo do_shortcode( '[cred-relationship-form form="completed-module-form" parent_item="$current" child_item="' . get_current_user_id() . '"]' );
return ob_get_clean();
}
I hope this helps and please let me know if you need further assistance.
So this essentially runs into the same problem, once logged the form loads properly but it doesn't submit and the child element appears empty (the Value is properly set to the user ID on inspection) but when you try to submit it just does nothing.
If you hit submit it just has a Ajax error, If you were to remove the child element from the shortcode and just manually find the post it works.
Can you please tell me what post you want to see when you load the form as well as admin access details and problem URL where I can see the form.
*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.
I have set the next reply to private which means only you and I have access to it.
Do you mean that you want to connect to the child where child post author is current loggedin user as you shared that the logged in user will have one post when user is created.
Can you please share one frontend user access details for whom you created the child post and tell me what child post you created for that frontend user then I will try to adjust the code for the form accordingly.
I have set the next reply to private which means only you and I have access to it.