Plugin Author
Kento
(@proaktion)
Hi!
You can use either of these approaches which rely on the actual implementation of the shortcode in templates:
a) Use do_shortcode() to render the output in a template, for example, to render the button that allows to join the “Premium” group:
<?php echo do_shortcode( '[groups_join group="Premium"]'); ?>
To render the button that allows to leave that group:
<?php echo do_shortcode( '[groups_leave group="Premium"]'); ?>
b) Use Groups’ underlying API functions directly in a template:
Button to join the “Premium” group:
<?php echo Groups_Shortcodes::groups_join( array( 'group' => 'Premium' ) ); ?>
… button to leave it:
<?php echo Groups_Shortcodes::groups_leave( array( 'group' => 'Premium' ) ); ?>
In this way, you still have the benefit of the shortcode that provides the functionality, without being limited to use it directly on the page content.
Plugin Author
Kento
(@proaktion)
I’ve expanded on the idea with an example showing a combination of Groups’ blocks and shortcodes in this article https://www.itthinx.com/2023/02/06/1-click-memberships-with-groups-for-wordpress/
The approach outside the WordPress editor is at the bottom of the article, but for those who look for a solution without templates, I think it’s useful to have the reference.