I'm working on a dynamic condition that should show an image if a user has booked a specific Amelia event. It seems that data from Amelia gets stored in 'wp_amelia_users'. How can i get a shortcode that pulls an array of all the events booked by the user?
Chatgpt gave me the code blow, but its not working.
// Define your shortcode function function amelia_user_booked_events_shortcode( $atts ) { // Extract attributes $atts = shortcode_atts( array( 'user_id' => get_current_user_id(), // Default to current user if not provided ), $atts );
// Retrieve booked events for the specified user global $wpdb; $user_id = intval( $atts['user_id'] ); $booked_events = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}amelia_users WHERE user_id = %d", $user_id ) );
// Initialize an array to hold the booked events data $events_data = array();
// Loop through booked events and construct array foreach ( $booked_events as $event ) { $event_data = array( 'event_name' => $event->event_name, // Assuming 'event_name' is the column name // Add more details about the event here as needed ); $events_data[] = $event_data; }
We do not have option to create dynamic URL and images. we will try to help but not sure if this is possible. Can you please send us a couple of screenshots of what you want to achieve exactly and where so that we can test this and see if this is possible or not.
I'm building a portal for a company that sells cosmetic training events. Some of their events are only open for people that have followed a specific pre-training event. Within Amelia it's not possible to add criteria that disallow users to book a training if they have not booked another 'pre-training' before.
I want to solve this with a workaround. I'm working with the plugins Elementor, Woocommerce and DynamicConditions (from RTO).
In a container (with the Elementor page builder) i will place the Amelia event display widget. In this widget i will only display follow-up events. With the DynamicConditions plugin i want to set a condition that the container only becomes visible when a user has bought a 'pre-training' in the past. In that way a user is not able to see the follow-up events if they have not followed the pre-training.
So somehow i need to retreive the event names, or ID's of the events a user has bought/followed. Then i can set a dynamic condition that either hides of shows the container with follow-up events.
Ive added an image of what I've tried to set up. Instead of hiding an Amelia event widget, I've tried it first with an image. It should work the same. In the image you will see that I've tried to search for the products in the WooCommerce database. But i want to set it up by searching in the 'wp_amelia_users' table for the products.
Thank you for the detailed explanation but we do not have any such option nor we can offer any guidelines since we have never encountered this. We are not at all sure if this can be achieved or not but in any case this is beyond of our support that we provide. But perhaps I can offer some other way of achieving this that seems much easier and that we so that some of other users use in case of membership which sort of your setup is.
Any membership plugin (like MemberPress, or Ultimate Member, etc.) allows you to create pages that are inaccessible to some (for example non-logged-in users). You can also create custom logic, so a user can access this page once a month (for example), but we're not sure about that, since we don't work with Membership plugins we know that some of out users were able to set some sort of membership and I hope this helps.
Should you have any further inquiries, we kindly request that you open separate tickets for each question and we will gladly help you there.
We wish you all the best and hope you have a wonderful day ahead.
Hi!
I'm working on a dynamic condition that should show an image if a user has booked a specific Amelia event. It seems that data from Amelia gets stored in 'wp_amelia_users'. How can i get a shortcode that pulls an array of all the events booked by the user?
Chatgpt gave me the code blow, but its not working.
// Define your shortcode function
function amelia_user_booked_events_shortcode( $atts ) {
// Extract attributes
$atts = shortcode_atts( array(
'user_id' => get_current_user_id(), // Default to current user if not provided
), $atts );
// Retrieve booked events for the specified user
global $wpdb;
$user_id = intval( $atts['user_id'] );
$booked_events = $wpdb->get_results( $wpdb->prepare(
"SELECT * FROM {$wpdb->prefix}amelia_users WHERE user_id = %d",
$user_id
) );
// Initialize an array to hold the booked events data
$events_data = array();
// Loop through booked events and construct array
foreach ( $booked_events as $event ) {
$event_data = array(
'event_name' => $event->event_name, // Assuming 'event_name' is the column name
// Add more details about the event here as needed
);
$events_data[] = $event_data;
}
return $events_data;
}
add_shortcode( 'amelia_user_booked_events', 'amelia_user_booked_events_shortcode' );
Attached files: Schermafbeelding 2024-03-16 102518.png
Schermafbeelding 2024-03-16 102539.png
Hello there,
Thank you for reaching out to us.
We do not have option to create dynamic URL and images. we will try to help but not sure if this is possible. Can you please send us a couple of screenshots of what you want to achieve exactly and where so that we can test this and see if this is possible or not.
Looking forward to your reply.
Kind Regards,
Marko Davidovic [email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, floor plans, choropleth maps, and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables
Hi Marko,
Thank you for your reply!
I will explain what I'm trying to build:
I'm building a portal for a company that sells cosmetic training events. Some of their events are only open for people that have followed a specific pre-training event. Within Amelia it's not possible to add criteria that disallow users to book a training if they have not booked another 'pre-training' before.
I want to solve this with a workaround. I'm working with the plugins Elementor, Woocommerce and DynamicConditions (from RTO).
In a container (with the Elementor page builder) i will place the Amelia event display widget. In this widget i will only display follow-up events. With the DynamicConditions plugin i want to set a condition that the container only becomes visible when a user has bought a 'pre-training' in the past. In that way a user is not able to see the follow-up events if they have not followed the pre-training.
So somehow i need to retreive the event names, or ID's of the events a user has bought/followed. Then i can set a dynamic condition that either hides of shows the container with follow-up events.
Ive added an image of what I've tried to set up. Instead of hiding an Amelia event widget, I've tried it first with an image. It should work the same. In the image you will see that I've tried to search for the products in the WooCommerce database. But i want to set it up by searching in the 'wp_amelia_users' table for the products.
Link to the image: https://ibb.co/Kh6c166
Can't seem to attach it to the post
Hello again,
Thank you for the detailed explanation but we do not have any such option nor we can offer any guidelines since we have never encountered this. We are not at all sure if this can be achieved or not but in any case this is beyond of our support that we provide. But perhaps I can offer some other way of achieving this that seems much easier and that we so that some of other users use in case of membership which sort of your setup is.
Any membership plugin (like MemberPress, or Ultimate Member, etc.) allows you to create pages that are inaccessible to some (for example non-logged-in users). You can also create custom logic, so a user can access this page once a month (for example), but we're not sure about that, since we don't work with Membership plugins we know that some of out users were able to set some sort of membership and I hope this helps.
Should you have any further inquiries, we kindly request that you open separate tickets for each question and we will gladly help you there.
We wish you all the best and hope you have a wonderful day ahead.
Kind Regards,
Marko Davidovic [email protected]
Rate my support
Try our FREE mapping plugin! MapSVG - easy Google maps, interactive SVG maps, floor plans, choropleth maps, and much more - https://wordpress.org/plugins/mapsvg-lite-interactive-vector-maps/
wpDataTables: FAQ | Facebook | Twitter | Instagram | Front-end and back-end demo | Docs
Amelia: FAQ | Facebook | Twitter | Instagram | Amelia demo sites | Docs | Discord Community
You can try wpDataTables add-ons before purchasing on these sandbox sites:
Powerful Filters | Gravity Forms Integration for wpDataTables | Formidable Forms Integration for wpDataTables | Master-Detail Tables