indeed-ultimate-membership-pro.php
1.57 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
<?php
if ( ! defined( 'ABSPATH' ) ) exit;
if( !is_plugin_active( 'indeed-membership-pro/indeed-membership-pro.php' ) ){
return;
}
class ACUI_IndeedMemberShipPro{
function __construct(){
add_filter( 'acui_restricted_fields', array( $this, 'restricted_fields' ), 10, 1 );
add_action( 'acui_documentation_after_plugins_activated', array( $this, 'documentation' ) );
add_action( 'post_acui_import_single_user', array( $this, 'import_single_user' ), 10, 3 );
}
function fields(){
return array( "level" );
}
function restricted_fields( $acui_restricted_fields ){
return array_merge( $acui_restricted_fields, $this->fields() );
}
function documentation(){
?>
<tr valign="top">
<th scope="row"><?php _e( "Indeed Ultimate Membership Pro is activated", 'import-users-from-csv-with-meta' ); ?></th>
<td>
<?php _e( "You can use the columns in the CSV in order to import data from Indeed Ultimate Membership Pro.", 'import-users-from-csv-with-meta' ); ?>.
<ul style="list-style:disc outside none; margin-left:2em;">
<li>level: you have to use the level id, you can find it in "Levels" tab</li>
</ul>
</td>
</tr>
<?php
}
function import_single_user( $headers, $row, $user_id ){
global $wpdb;
$keys = $this->fields();
$columns = array();
foreach ( $keys as $key ) {
$pos = array_search( $key, $headers );
if( $pos !== FALSE ){
$columns[ $key ] = $pos;
$$key = $row[ $columns[ $key ] ];
}
}
if( !empty( $level ) )
$level = ihc_do_complete_level_assign_from_ap( $user_id, $level );
}
}
new ACUI_IndeedMemberShipPro();