single-group.php
6.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
<?php
get_header();
$ulgm_group_slug = sanitize_text_field( wp_unslash( get_query_var( 'ulgm_group_slug' ) ) );
$args = array(
'name' => $ulgm_group_slug,
'post_type' => 'groups',
'post_status' => 'publish',
'no_found_rows' => true,
'numberposts' => 1
);
$group_query = new WP_query();
$group_query->query( $args );
?>
<style>
.post-pagination-wrap,
.post-pagination,
.post-prev,
.post-next {
display: none !important;
}
</style>
<div id="main-content">
<div id="group-main" class="page type-page status-publish hentry">
<div class="entry-content">
<div id="left-area" class="content-area clr">
<main id="content" class="site-content clr" role="main">
<?php
if ( $group_query->have_posts() ) :
while ( $group_query->have_posts() ) :
$group_query->the_post();
// lets check for key
$group_key = crypt( $post->ID, 'uncanny-group' );
//Fixing $_GET string from . (dot) & space to _ ( underscore )
$group_key = str_replace( array( ' ', '.', '[', '-' ), '_', $group_key );
if ( ! isset( $_GET[ $group_key ] ) ) {
?>
<p><?php echo esc_html__( 'This page can only be used by organizations with a valid group ID. The URL used to reach this page is not valid. Please contact your organization to obtain the correct registration URL.', 'uncanny-pro-toolkit' ); ?></p>
<?php
if ( current_user_can( 'manage_options' ) ) {
printf(
'<h2>' . esc_attr__( 'Shown to admins only.', 'uncanny-pro-toolkit' ) . '</h2>' . '<p>' . esc_attr__( 'The sign up link for this group is:', 'uncanny-pro-toolkit' ) . ' <br /><a href="%1$s" >%1$s</a></p>',
add_query_arg(
array(
'gid' => get_the_ID(),
),
site_url( 'sign-up/' . $post->post_name . '/' )
) . '&' . $group_key
);
}
} else {
?>
<article <?php post_class(); ?>>
<?php
if ( ! is_user_logged_in() ) {
if ( ! isset( $_REQUEST['registered'] ) ) {
$show_content = true;
if ( class_exists( '\uncanny_learndash_groups\SharedFunctions' ) ) {
$code_group_id = get_post_meta( get_the_ID(), '_ulgm_code_group_id', true );
if ( $code_group_id ) {
$remaining_seats = \uncanny_learndash_groups\SharedFunctions::remaining_seats( get_the_ID() );
if ( 0 === $remaining_seats ) {
echo '<div class="uncanny_group_signup_form-container">';
echo esc_attr__( 'Sorry, no more seats are available for this group.', 'uncanny-pro-toolkit' );
echo '</div>';
$show_content = false;
}
}
}
if ( $show_content ) {
echo do_shortcode( do_blocks( $post->post_content ) );
}
$is_gravityform_block = false;
if ( function_exists( 'has_blocks' ) ) {
if ( has_blocks( $post->post_content ) ) {
$blocks = parse_blocks( $post->post_content );
foreach ( $blocks as $block ) {
if ( $block['blockName'] === 'gravityforms/form' ) {
$is_gravityform_block = true;
break;
}
}
}
}
if ( ! has_shortcode( $post->post_content, 'gravityform' ) && ! has_shortcode( $post->post_content, 'theme-my-login' ) && $is_gravityform_block === false ) {
if ( $show_content ) {
\uncanny_pro_toolkit\LearnDashGroupSignUp::groups_register_form();
}
}
} else {
?>
<?php
$frontEndLogin = \uncanny_learndash_toolkit\Config::get_settings_value( 'uo_frontendloginplus_needs_verifcation', 'FrontendLoginPlus' );
if ( ! empty( $frontEndLogin ) && 'on' === $frontEndLogin ) {
?>
<p><?php echo esc_html__( 'Thank you for registering. Your account needs to be approved by site administrator.', 'uncanny-pro-toolkit' ); ?></p>
<?php } else { ?>
<p><?php echo esc_html__( 'Congratulations! You are now registered on this site. You will receive an email shortly with login details.', 'uncanny-pro-toolkit' ); ?></p>
<?php } ?>
<?php
}
} elseif ( is_user_logged_in() && isset( $_REQUEST['registered'] ) ) {
?>
<p><?php echo esc_html__( 'Congratulations! You are now registered on this site.', 'uncanny-pro-toolkit' ); ?></p>
<?php
} elseif ( is_user_logged_in() && isset( $_REQUEST['joined'] ) ) {
?>
<p>
<?php
if ( isset( $_REQUEST['msg'] ) && $_REQUEST['msg'] === '2' ) {
echo esc_html__( 'Congratulations! You have successfully joined the new group and have been removed from the previous group.', 'uncanny-pro-toolkit' );
} else {
echo esc_html__( 'Congratulations! You are now a member of this group.', 'uncanny-pro-toolkit' );
}
?>
</p>
<?php
} else {
$show_content = true;
$user_id = get_current_user_id();
$meta = get_user_meta( $user_id, 'learndash_group_users_' . get_the_ID(), true );
if ( ! empty( $meta ) ) {
echo '<div class="uncanny_group_signup_form-container">';
echo esc_attr__( 'You are already in this group.', 'uncanny-pro-toolkit' );
echo '</div>';
$show_content = false;
}
if ( class_exists( '\uncanny_learndash_groups\SharedFunctions' ) && $show_content ) {
$code_group_id = get_post_meta( get_the_ID(), '_ulgm_code_group_id', true );
if ( $code_group_id ) {
$remaining_seats = \uncanny_learndash_groups\SharedFunctions::remaining_seats( get_the_ID() );
if ( 0 === $remaining_seats ) {
echo '<div class="uncanny_group_signup_form-container">';
echo esc_attr__( 'Sorry, no more seats are available for this group.', 'uncanny-pro-toolkit' );
echo '</div>';
$show_content = false;
}
}
}
if ( $show_content ) {
echo \uncanny_pro_toolkit\LearnDashGroupSignUp::groups_login_form();
echo \uncanny_pro_toolkit\LearnDashGroupSignUp::check_group_membership();
}
}
?>
</article><!-- .entry -->
<?php
}
wp_reset_postdata();
endwhile;
else:
?>
<p><?php echo esc_html__( 'Page not found.', 'uncanny-pro-toolkit' ); ?></p>
<?php
endif;
?>
</main>
</div>
<div id="right-area" class="sidebar">
<?php
if ( isset( $_GET[ $group_key ] ) ) {
echo do_shortcode( '[uo_group_organization]' );
}
if ( ! is_user_logged_in() ) {
echo do_shortcode( '[uo_group_login]' );
}
?>
</div>
</div>
</div><!-- .container -->
</div>
<?php
get_footer();