Hi Christian,
I need to get into the problem again :-}
What still needs to be done:
1) When a trainer (=user) makes a new training (=event) (both cpt's), this user is no langer added to the event.
2) As a result: on the eventpage the user is not shown.
Tomorrow I will work on it. In the meantime, maybe the two questions above are easy 🙂 ?
Shane
Supporter
Languages:
English (English )
Timezone:
America/Jamaica (GMT-05:00)
Charlotte,
Christian is currently on a public holiday today but he will be back tomorrow to continue helping here.
Thanks,
Shane
Thanks Shane.
In the meantime I tried to go further, but I do not comprehend how to do it. So for Christian, i will put the problem as straight as I can.
In postform: 'Training aanmaken' (make event) I expect to be able to add the trainer (=user) as a relationship formfield.
There is no such thing so I can't connect the actual user with the training (event).
That's it. The rest works.
So long,
Charlotte
Hi, neither of the plus account trainer logins I have access to are working now. Can you check the logins and provide an updated trainer login I can use for testing?
Okay I have added the following code to your functions.php file:
add_action('cred_save_data', 'ts_link_author_trainer_to_training',10,2);
function ts_link_author_trainer_to_training($post_id, $form_data)
{
global $current_user;
wp_get_current_user();
// if a specific form
if ($form_data['id']==541)
{
// get the Training post created by the current User
$trainer_args = array(
'post_type'=>'trainer',
'numberposts'=>1,
'author'=>$current_user->ID,
);
$trainer_res = get_posts( $trainer_args );
if(isset($trainer_res[0])) {
$trainer = $trainer_res[0];
// connect the trainer and the training just created by Forms
toolset_connect_posts( 'trainer-activiteit', $trainer->ID, $post_id );
}
}
}
This code should automatically connect the Trainer post and the Training post when a User submits the Training aanmaken Form. Can I test this out on the site, or would you prefer to test it?
Hi Christian,
I tested, made a test-event and indeed via the admin I can see that the Trainer is automatically connected to the post. Only (!) to my surprise it does not show up on the frontend where it should: hidden link
This is the single-page template.
I will leave the test for a while so you can see and test further yourself.
Also the link on the accountpage: 'Connect another Trainer' does not work.
Thanks so far,
have a nice day!
Charlotte
Ai!!! I discovered that in all posts the trainer name has disappeared. I tried to add a new view to the template 'Een training'.
I did not succeed!
So I thought to remove the code from functions.php for now. But still the names (with link to the Trainer-profilepage does not show up. It this piece of code: [wpv-view name="meerdere-trainers"]
If you please help!
greetings
Charlotte
Oef, I put the old link back: , but then it's only the post-author.
For now it's okay,
Bye
Check the Trainingen Template Layout. Where can I find the "meerdere-trainers" View?
<p><span class="kopje">Trainer:[wpv-view name="meerdere-trainers"]</span></p>
Hi Christian,
This view (meerdere-trainers) disappeared !???
I tried to make a new one (connected-trainers), but I don't know how to do it so that the connected trainers are shown. Pfff, I feel confused about the relationships option.
Maybe you will help me with this, otherwise I must have a tutorial. Which is there that I can follow?
Have a nice day,
Charlotte
We want to show Trainers that are connected to the current Training post. So I added a "Post Relationship" filter and chose to show Trainers in the relationship "Trainer", connected to the post where this View is shown. See the screenshots here. Now you may want to remove the post author shortcode from the Layout so it's not repeated.
Hi Christian,
I don't see the view you made.
I tried to make this same filter in the view: 'Connected trainers' and placed this view in de Layout: 'Een training'.
It does not work. What am I doing wrong?
Please have a look at 'Connected -trainers'
Your activity results in that I see my own name as under Trainer as long as I'm I'm logged in, see screenshot.
Thanks sofar, nearly there,
Charlotte
The problem is here in the Loop editor:
[wpv-user field="user_firstname"]
[wpv-user field="user_lastname"]
The wpv-user shortcode displays information about the current, logged-in User unless it is placed in a View of Users. This is not a View of Users, it's a View of Trainers. So you can use a wpv-post-title shortcode to display the Trainer post title instead. If you need to display the User's information, then you need to determine the author of the Trainer post in the loop using the wpv-post-author shortcode. You can find documentation for these shortcodes here: https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-author
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-user
Hi,
Yes, I mended this 🙂
Only the code to connect another trainer does not work:
[cred-relationship-form-link form='toolset-trainers-trainingen' child_item='$current' layout_slug='toolset-trainers-trainingen-relationship-form']Connect another Trainer[/cred-relationship-form-link]
It leads to a blank page.
I don't have time at the moment, so maybe we should close this topic for now.
Thanks very much for the help,
Have a nice day!
Charlotte