|
1 | 1 | <?php |
2 | 2 | /** |
3 | | - * Gravity Perks // Better User Activation // Conditional Activation Pages |
4 | | - * https://gravitywiz.com/documentation/gravity-forms-better-user-activation/ |
5 | | - * |
6 | | - * This experimental snippet allows you to load a different activation page depending on a value |
7 | | - * in its associated entry. |
| 3 | + * We're no longer using the experimental folder for experimental snippets. 🚧 |
| 4 | + * You can now find the snippet here: |
| 5 | + * https://github.com/gravitywiz/snippet-library/blob/master/gp-better-user-activation/gpbua-conditional-activation-pages.php |
8 | 6 | */ |
9 | | -add_filter( 'gpbua_activation_page_id', function( $activation_page_id ) { |
10 | | - |
11 | | - // Update "1234" to the ID of your conditional activation page. Add additional page IDs as needed. |
12 | | - $activation_page_ids = array( $activation_page_id, 1234 ); |
13 | | - |
14 | | - // Allow conditional activation pages to be treated as activation pages in the post editor. |
15 | | - if ( is_admin() ) { |
16 | | - if ( in_array( rgget( 'post' ), $activation_page_ids ) ) { |
17 | | - return (int) rgget( 'post' ); |
18 | | - } elseif ( in_array( rgpost( 'post_ID' ), $activation_page_ids ) ) { |
19 | | - return (int) rgpost( 'post_ID' ); |
20 | | - } |
21 | | - } |
22 | | - |
23 | | - parse_str( $_SERVER['QUERY_STRING'], $query_args ); |
24 | | - $activation_key = rgar( $query_args, 'key', rgar( $query_args, 'gfur_activation' ) ); |
25 | | - if ( ! $activation_key ) { |
26 | | - return $activation_page_id; |
27 | | - } |
28 | | - |
29 | | - require_once( gf_user_registration()->get_base_path() . '/includes/signups.php' ); |
30 | | - global $wpdb; |
31 | | - $wpdb->signups = $wpdb->base_prefix . 'signups'; |
32 | | - |
33 | | - $signup = GFSignup::get( $activation_key ); |
34 | | - if ( is_wp_error( $signup ) ) { |
35 | | - if ( $signup->get_error_code() !== 'already_active' ) { |
36 | | - return $activation_page_id; |
37 | | - } |
38 | | - $meta = unserialize( $signup->error_data['already_active']->meta ); |
39 | | - $entry = GFAPI::get_entry( $meta['lead_id'] ); |
40 | | - } else { |
41 | | - $entry = $signup->lead; |
42 | | - } |
43 | | - |
44 | | - // Update "5" to the field ID for whose value the conditional will be based. |
45 | | - $value = $entry[5]; |
46 | | - |
47 | | - switch ( $value ) { |
48 | | - // Update "my_custom_value" to the entry value that should trigger the conditional activation page. |
49 | | - case 'my_custom_value': |
50 | | - $activation_page_id = 3105; |
51 | | - break; |
52 | | - } |
53 | | - |
54 | | - return $activation_page_id; |
55 | | -} ); |
0 commit comments