コード例 #1
0
function buatp_directory_setup()
{
    $buatp_general_settings = get_option('buatp_basic_setting', true);
    global $bp;
    if (bp_is_buatp_component() && !$bp->current_action) {
        if ($buatp_general_settings['buatp_default_type_selection']) {
            bp_core_redirect(buatp_get_type_directory_url($buatp_general_settings['buatp_default_type_selection']));
        } else {
            bp_core_redirect(site_url());
        }
    } else {
        if (bp_is_buatp_component() && $bp->current_action) {
            if ($bp->buatp->directory_id) {
                do_action('buatp_directory_setup');
                bp_core_load_template(apply_filters('buatp_directory_template', 'members/members-loop'));
            } else {
                bp_core_redirect(site_url());
            }
        }
    }
}
コード例 #2
0
 function buatp_basic_setting_page()
 {
     $setting_fields = array();
     $setting_fields = array(array('name' => 'buatp_type_field_selection', 'class' => 'buatp_type_field_selection', 'label' => __('Select type defining field', 'buatp'), 'desc' => __('User will select his/her own type during registration, which field will define user types', 'buatp'), 'type' => 'select', 'options' => array_merge(array('null' => '------'), buatp_get_all_select_box_fields())));
     if (isset($_POST['buatp_default_type_selection'])) {
         $this->buatp_basic_setting['buatp_default_type_selection'] = $_POST['buatp_default_type_selection'];
         $this->buatp_basic_setting['buatp_is_triggerd'] = 0;
     }
     if (isset($_POST['buatp_selected_field']) || isset($this->buatp_basic_setting['buatp_default_type_selection']) && $this->buatp_basic_setting['buatp_default_type_selection']) {
         $not_configured = true;
     } else {
         $not_configured = false;
     }
     if ($not_configured) {
         $field_name = $this->buatp_basic_setting['buatp_type_field_selection'];
         if (isset($_POST['buatp_selected_field'])) {
             $field_name = $_POST['buatp_selected_field'];
             $this->buatp_type_field_id = buatp_get_field_id_by_name($field_name);
         }
         $this->buatp_basic_setting['buatp_type_field_selection'] = $field_name;
         $this->buatp_update_option('buatp_basic_setting', $this->buatp_basic_setting);
         $this->buatp_set_all_type_info();
         $page_list[0] = array('name' => 'buatp_page_selection', 'class' => 'buatp_page_selection', 'label' => __(sprintf('Select root page'), 'buatp'), 'desc' => __(sprintf('<br>Select root page of user account type. This page will show nothing but rediect to deault user type directory.
                                <br>Also this page will work as root slug of user type directories. For example, if you select "User Type" page as Root Page, 
                                and if you have user type named "teachers", teachers directory URL will be 
                                <br><b>%1$s/user-type/teachers</b>', site_url()), 'buatp'), 'type' => 'select', 'options' => $this->page_array);
         foreach ((array) $this->all_type_info as $val) {
             $i++;
             $slug_list[$i] = array('name' => 'buatp_slug_selection_for_' . $val['id'], 'class' => 'buatp_slug_selection buatp_slug_selection_for_' . $val['id'], 'label' => __(sprintf('Slug for <strong>%1$s</strong> type users', $val['name']), 'buatp'), 'type' => 'text', 'desc' => __(sprintf('URL: %1$s<br>Slug to show <strong>%2$s</strong> type users, no spacial characters, uppercase or spaces.', buatp_get_type_directory_url($val['name']), $val['name']), 'buatp'), 'default' => buatp_get_type_directory_slug($val['name']));
             $roles_list[$i] = array('name' => 'buatp_role_selection_for_' . $val['id'], 'class' => 'buatp_role_selection_for_' . $val['id'], 'label' => __(sprintf('Select role for <strong>%1$s</strong> type users', $val['name']), 'buatp'), 'desc' => __(sprintf('<strong>%1$s</strong> type users role, by default,subscriber ', $val['name']), 'buatp'), 'type' => 'select', 'options' => buatp_get_all_roles());
         }
         /*
         if( !$this->buatp_basic_setting['buatp_manage_existing_users'] ):
         
         $exisiting_roles = array(
                 array(
                 'name' => 'buatp_manage_existing_users',
                 'class' => 'buatp_manage_existing_users',
                 'label' => __( 'Whats about existing users?', 'buatp' ),
                 'desc' => __( 'What you want to do with exisitng users, you may assign then all to default type,<br>
                                or can change type according to their role','buatp' ),
                 'type' => 'radio',
                 'options' => array(
                         'false' => 'Do Nothing',
                         'role_to_type_force' => 'Force assign type according to role( Override type even if user already have type )',
                         'role_to_type' => 'Assign type according to role( assign types only to those user who have no type assigned )',
                         'default_type_to_all_force' => 'Force assign default type to all( Override all types to default type )',
                         'default_type_to_all' => 'Assign default type to all( assign default type only to those user who have no type assigned )',
                         )
                  ),
             );
         
         foreach( buatp_get_all_roles() as $role ) {
             $j++;
             $options = array_merge(array('false' => '----------'),buatp_get_all_types($this->buatp_type_field_id,'name','single'));
             $exisiting_roles_to_type[$j] = array(
                 'name' => 'buatp_role_to_type_for_'.strtolower($role),
                 'class' => 'buatp_role_to_type_for_'.$role.' buatp_role_to_type',
                 'label' => __( sprintf('Select type for <strong>%1$s</strong> users', $role), 'buatp' ),
                 'desc' => __( sprintf('<strong>%1$s</strong> users will be converted to seleted type', $role), 'buatp' ),
                 'type' => 'select',
                 'options' => $options,
                 'default' => 'false'
             );
         }
         $exisiting_roles = array_merge($exisiting_roles,$exisiting_roles_to_type);
         else:
             $exisiting_roles = array(
                 array(
                     'name' => 'buatp_change_all_existing_users_role',
                     'class' => 'buatp_change_all_existing_users_role',
                     'label' => __( sprintf('Change current users role according to type', $role), 'buatp' ),
                     'desc' => __( sprintf('You can update current user roles depanding on user type, that you selected before', $role), 'buatp' ),
                     'type' => 'select',
                     'options' => array('true'=>'Yes','false' => 'No'),
                     'default' => 'false'
             ),
                 array(
                     'name' => 'buatp_manage_existing_users',
                     'class' => 'buatp_manage_existing_users',
                     'type' => 'hidden',
                     'value' => 'false'
                     ),
             );
         endif;
         */
         $conditionals = array('name' => 'buatp_default_type_selection', 'class' => 'buatp_default_type_selection', 'label' => __('Select default type', 'buatp'), 'desc' => __('User will obtain this type by default', 'buatp'), 'type' => 'select', 'options' => $this->type_array);
         $more_basic_fields = array(array('name' => 'buatp_exclude_id_for_roles', 'class' => 'buatp_exclude_id_for_roles', 'label' => __('Exclude IDs from change role<br>( comma sapareted )', 'buatp'), 'desc' => __('<br>You may exclude some ids to prevent them from changing roles,admin\'s id (1) will be excluded bu default', 'buatp'), 'type' => 'text', 'default' => '1'), array('name' => 'buatp_users_per_page', 'class' => 'buatp_users_per_page', 'label' => __('Users to display per page', 'buatp'), 'desc' => __('<br>By default, BuddyPress shows 10 users per page, how many users you want to show per page?', 'buatp'), 'type' => 'text', 'default' => '10'), array('name' => 'buatp_can_user_change_type', 'class' => 'buatp_can_user_change_type', 'label' => __('Can user change type after registration?', 'buatp'), 'desc' => __('User may change own type after registration from his/her buddypress profile, Do you want to allow this? By default, No
                         <br> If you select \'No\', Then, only <strong>site admin</strong> can view or change user type', 'buatp'), 'type' => 'radio', 'options' => array('true' => 'Yes', 'false' => 'No'), 'default' => array('false' => 'No')), array('name' => 'buatp_is_triggerd', 'class' => 'buatp_is_triggerd', 'type' => 'hidden', 'value' => 0));
         $setting_fields = array_merge($setting_fields, array($conditionals));
         $setting_fields = array_merge($setting_fields, $page_list, (array) $slug_list, $roles_list, (array) $exisiting_roles, $more_basic_fields);
     }
     return (array) $setting_fields;
 }