forked from strangerstudios/pmpro-add-member-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pmpro-add-member-admin.php
110 lines (95 loc) · 3.54 KB
/
pmpro-add-member-admin.php
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
<?php
/*
Plugin Name: Paid Memberships Pro - Add Member Admin
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-add-member-admin/
Description: Allow admins to add members in the WP dashboard.
Version: .3
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
Text Domain: pmpro-add-member-admin
Domain Path: /languages
*/
/*
* Add "Add Member" link under Memberships.
* Form with fields, username, email (find user), password (random), name, level, expiration (auto), credit card
* Add user, apply level, save order
* Filters for adding additional fields.
*/
/*
Add Menu Item
*/
function pmproama_pmpro_add_pages()
{
$cap = apply_filters('pmpro_add_member_cap', 'edit_users');
add_submenu_page('pmpro-membershiplevels', __('Add Member', 'pmpro-add-member-admin'), __('Add Member', 'pmpro-add-member-admin'), $cap, 'pmpro-addmember', 'pmpro_addmember');
}
add_action('admin_menu', 'pmproama_pmpro_add_pages');
function pmpro_addmember()
{
require_once(dirname(__FILE__) . "/adminpages/addmember.php");
}
/*
Admin Bar
*/
function pmproama_admin_bar_menu() {
global $wp_admin_bar;
//view menu at all?
if ( !current_user_can('pmpro_memberships_menu') || !is_admin_bar_showing() )
return;
$cap = apply_filters('pmpro_add_member_cap', 'edit_users');
if(current_user_can($cap))
$wp_admin_bar->add_menu( array(
'id' => 'pmpro-addmember',
'parent' => 'paid-memberships-pro',
'title' => __( 'Add Member', 'pmpro-add-member-admin'),
'href' => get_admin_url(NULL, '/admin.php?page=pmpro-addmember') ) );
}
add_action('admin_bar_menu', 'pmproama_admin_bar_menu', 1001);
/*
Function to add links to the plugin action links
*/
function pmproama_add_action_links($links) {
$cap = apply_filters('pmpro_add_member_cap', 'edit_users');
if(current_user_can($cap))
{
$new_links = array(
'<a href="' . get_admin_url(NULL, 'admin.php?page=pmpro-addmember') . '">' . __( 'Add Member', 'pmpro-add-member-admin') . '</a>',
);
}
return array_merge($new_links, $links);
}
add_filter('plugin_action_links_' . plugin_basename(__FILE__), 'pmproama_add_action_links');
/*
Function to add links to the plugin row meta
*/
function pmproama_plugin_row_meta($links, $file) {
if(strpos($file, 'pmpro-add-member-admin.php') !== false)
{
$new_links = array(
'<a href="' . esc_url( 'http://paidmembershipspro.com/support/') . '" title="' . esc_attr( __( 'Visit Customer Support Forum', 'pmpro-add-member-admin' ) ) . '">' . __( 'Support', 'pmpro-add-member-admin' ) . '</a>',
);
$links = array_merge($links, $new_links);
}
return $links;
}
add_filter('plugin_row_meta', 'pmproama_plugin_row_meta', 10, 2);
/*
Add action links
*/
function pmproama_action_links($actions, $user)
{
$cap = apply_filters('pmpro_add_member_cap', 'edit_users');
if(current_user_can($cap) && !empty($user->ID))
$actions['addorder'] = '<a href="' . admin_url('admin.php?page=pmpro-addmember&user=' . $user->ID) . '">' . __( '+order', 'pmpro-add-member-admin' ) . '</a>';
return $actions;
}
add_filter('pmpro_memberslist_user_row_actions', 'pmproama_action_links', 10, 2);
add_filter('pmpro_orders_user_row_actions', 'pmproama_action_links', 10, 2);
add_filter('user_row_actions', 'pmproama_action_links', 10, 2);
/**
* Load Plugin Text Domain for I18N.
*/
function pmproama_load_plugin_textdomain() {
load_plugin_textdomain( 'pmpro-add-member-admin', false, basename( dirname( __FILE__ ) ) . '/languages' );
}
add_action( 'plugins_loaded', 'pmproama_load_plugin_textdomain' );