LLMS_Meta_Box_Membership::get_fields()

This function is where extending classes can configure all the fields within the metabox.


Description Description

The function must return an array which can be consumed by the "output" function.


Top ↑

Return Return

(array)


Top ↑

Source Source

File: includes/admin/post-types/meta-boxes/class.llms.meta.box.membership.php

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
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
public function get_fields() {
 
    global $post;
 
    $membership = new LLMS_Membership( $this->post );
 
    $redirect_options = array();
    $redirect_page_id = $membership->get( 'redirect_page_id' );
    if ( $redirect_page_id ) {
        $redirect_options[] = array(
            'key'   => $redirect_page_id,
            'title' => get_the_title( $redirect_page_id ) . '(ID#' . $redirect_page_id . ')',
        );
    }
 
    $sales_page_content_type = 'none';
    if ( $post && 'auto-draft' !== $post->post_status && $post->post_excerpt ) {
        $sales_page_content_type = 'content';
    }
 
    return array(
        array(
            'title'  => __( 'Sales Page', 'lifterlms' ),
            'fields' => array(
                array(
                    'allow_null'    => false,
                    'class'         => 'llms-select2',
                    'desc'          => __( 'Customize the content displayed to visitors and students who are not enrolled in the membership.', 'lifterlms' ),
                    'desc_class'    => 'd-3of4 t-3of4 m-1of2',
                    'default'       => $sales_page_content_type,
                    'id'            => $this->prefix . 'sales_page_content_type',
                    'is_controller' => true,
                    'label'         => __( 'Sales Page Content', 'lifterlms' ),
                    'type'          => 'select',
                    'value'         => llms_get_sales_page_types(),
                ),
                array(
                    'controller'       => '#' . $this->prefix . 'sales_page_content_type',
                    'controller_value' => 'content',
                    'desc'             => __( 'This content will only be shown to visitors who are not enrolled in this membership.', 'lifterlms' ),
                    'id'               => '',
                    'label'            => __( 'Sales Page Custom Content', 'lifterlms' ),
                    'type'             => 'post-excerpt',
                ),
                array(
                    'controller'       => '#' . $this->prefix . 'sales_page_content_type',
                    'controller_value' => 'page',
                    'data_attributes'  => array(
                        'post-type'   => 'page',
                        'placeholder' => __( 'Select a page', 'lifterlms' ),
                    ),
                    'class'            => 'llms-select2-post',
                    'id'               => $this->prefix . 'sales_page_content_page_id',
                    'type'             => 'select',
                    'label'            => __( 'Select a Page', 'lifterlms' ),
                    'value'            => $membership->get( 'sales_page_content_page_id' ) ? llms_make_select2_post_array( array( $membership->get( 'sales_page_content_page_id' ) ) ) : array(),
                ),
                array(
                    'controller'       => '#' . $this->prefix . 'sales_page_content_type',
                    'controller_value' => 'url',
                    'type'             => 'text',
                    'label'            => __( 'Sales Page Redirect URL', 'lifterlms' ),
                    'id'               => $this->prefix . 'sales_page_content_url',
                    'class'            => 'input-full',
                    'value'            => '',
                    'desc_class'       => 'd-all',
                    'group'            => 'top',
                ),
 
            ),
        ),
 
        array(
            'title'  => __( 'Restrictions', 'lifterlms' ),
            'fields' => array(
                array(
                    'allow_null'    => false,
                    'class'         => '',
                    'desc'          => __( 'When a non-member attempts to access content restricted to this membership', 'lifterlms' ),
                    'id'            => $this->prefix . 'restriction_redirect_type',
                    'is_controller' => true,
                    'type'          => 'select',
                    'label'         => __( 'Restricted Access Redirect', 'lifterlms' ),
                    'value'         => array(
                        array(
                            'key'   => 'none',
                            'title' => __( 'Stay on page', 'lifterlms' ),
                        ),
                        array(
                            'key'   => 'membership',
                            'title' => __( 'Redirect to this membership page', 'lifterlms' ),
                        ),
                        array(
                            'key'   => 'page',
                            'title' => __( 'Redirect to a WordPress page', 'lifterlms' ),
                        ),
                        array(
                            'key'   => 'custom',
                            'title' => __( 'Redirect to a Custom URL', 'lifterlms' ),
                        ),
                    ),
                ),
                array(
                    'class'            => 'llms-select2-post',
                    'controller'       => '#' . $this->prefix . 'restriction_redirect_type',
                    'controller_value' => 'page',
                    'data_attributes'  => array(
                        'post-type' => 'page',
                    ),
                    'id'               => $this->prefix . 'redirect_page_id',
                    'label'            => __( 'Select a WordPress Page', 'lifterlms' ),
                    'type'             => 'select',
                    'value'            => $redirect_options,
                ),
                array(
                    'class'            => '',
                    'controller'       => '#' . $this->prefix . 'restriction_redirect_type',
                    'controller_value' => 'custom',
                    'id'               => $this->prefix . 'redirect_custom_url',
                    'label'            => __( 'Enter a Custom URL', 'lifterlms' ),
                    'type'             => 'text',
                    'value'            => 'test',
                ),
                array(
                    'class'      => '',
                    'controls'   => '#' . $this->prefix . 'restriction_notice',
                    'default'    => 'yes',
                    'desc'       => __( 'Check this box to output a message after redirecting. If no redirect is selected this message will replace the normal content that would be displayed.', 'lifterlms' ),
                    'desc_class' => 'd-3of4 t-3of4 m-1of2',
                    'id'         => $this->prefix . 'restriction_add_notice',
                    'label'      => __( 'Display a Message', 'lifterlms' ),
                    'type'       => 'checkbox',
                    'value'      => 'yes',
                ),
                array(
                    'class'    => 'full-width',
                    'desc'     => sprintf( __( 'Shortcodes like %s can be used in this message', 'lifterlms' ), '[lifterlms_membership_link id="' . $this->post->ID . '"]' ),
                    'default'  => sprintf( __( 'You must belong to the %s membership to access this content.', 'lifterlms' ), '[lifterlms_membership_link id="' . $this->post->ID . '"]' ),
                    'id'       => $this->prefix . 'restriction_notice',
                    'label'    => __( 'Restricted Content Notice', 'lifterlms' ),
                    'type'     => 'text',
                    'sanitize' => 'shortcode',
                ),
            ),
        ),
 
        array(
            'title'  => __( 'Auto Enrollment', 'lifterlms' ),
            'fields' => array(
                array(
                    'label'      => __( 'Automatic Enrollment', 'lifterlms' ),
                    'desc'       => sprintf( __( 'When a student joins this membership they will be automatically enrolled in these courses. Click %1$shere%2$s for more information.', 'lifterlms' ), '<a href="https://lifterlms.com/docs/membership-auto-enrollment/" target="_blank">', '</a>' ),
                    'id'         => $this->prefix . 'content_table',
                    'titles'     => array( '', __( 'Course Name', 'lifterlms' ), '' ),
                    'type'       => 'table',
                    'table_data' => $this->get_content_table( $membership ),
                ),
                array(
                    'class'           => 'llms-select2-post',
                    'data_attributes' => array(
                        'placeholder'    => __( 'Select course(s)', 'lifterlms' ),
                        'post-type'      => 'course',
                        'no-view-button' => true,
                    ),
                    'id'              => $this->prefix . 'auto_enroll',
                    'label'           => __( 'Add Course(s)', 'lifterlms' ),
                    'type'            => 'select',
                    'value'           => array(),
                ),
            ),
        ),
    );
}


Top ↑

Changelog Changelog

Changelog
Version Description
3.36.0 Allow some fields to store values with quotes.
3.30.3 Removed duplicate array keys.
3.30.0 Removed empty field settings. Modified settings to accommodate sortable auto-enrollment table.
3.0.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.