Members::get_meta_fields()

Returns the available meta fields for the submodule.

Description

See also

Return

(array) Associative array of <code>$field_slug => $field_args</code> pairs.

Source

File: src/modules/access-controls/members.php

	public function get_meta_fields() {
		$meta_fields = parent::get_meta_fields();

		$role_choices = array();
		foreach ( wp_roles()->roles as $role => $details ) {
			$role_choices[ $role ] = translate_user_role( $details['name'] );
		}

		$meta_fields['allowed_roles'] = array(
			'type'        => count( $role_choices ) > 8 ? 'multiselect' : 'multibox',
			'label'       => __( 'Allowed Roles', 'torro-forms' ),
			'description' => __( 'If you select user roles here, only users with these roles are granted access to the form.', 'torro-forms' ),
			'choices'     => $role_choices,
		);

		$meta_fields['allowed_users'] = array(
			'type'          => 'autocompletewithbutton',
			'label'         => __( 'Allowed Users', 'torro-forms' ),
			'description'   => __( 'If you select users here, only these users are granted access to the form.', 'torro-forms' ),
			'repeatable'    => true,
			'autocomplete'  => array(
				'rest_placeholder_search_route' => 'wp/v2/users?search=%search%',
				'rest_placeholder_label_route'  => 'wp/v2/users/%value%',
				'value_generator'               => '%id%',
				/* translators: 1: user display name, 2: user ID */
				'label_generator'               => sprintf( __( '%1$s (User ID %2$s)', 'torro-forms' ), '%name%', '%id%' ),
			),
			'input_classes' => array( 'torro-member-invitation-input' ),
			'button_label'  => __( 'Send Invitation', 'torro-forms' ),
			'button_attrs'  => array(
				'class'    => 'button-link torro-send-invitation',
				'disabled' => true,
			),
		);

		$meta_fields['login_required_message'] = array(
			'type'          => 'text',
			'label'         => __( '&#8220;Login required&#8221; Message', 'torro-forms' ),
			'description'   => __( 'Enter the message to show to the user in case they are not logged in.', 'torro-forms' ),
			'default'       => $this->get_default_login_required_message(),
			'input_classes' => array( 'regular-text' ),
			'wrap_classes'  => array( 'has-torro-tooltip-description' ),
		);

		$meta_fields['not_selected_message'] = array(
			'type'          => 'text',
			'label'         => __( '&#8220;Not eligible&#8221; Message', 'torro-forms' ),
			'description'   => __( 'Enter the message to show to the user when they are logged in, but have not been selected to participate.', 'torro-forms' ),
			'default'       => $this->get_default_not_selected_message(),
			'input_classes' => array( 'regular-text' ),
			'wrap_classes'  => array( 'has-torro-tooltip-description' ),
		);

		return $meta_fields;
	}

Changelog

Changelog
Version Description
1.0.0 Introduced.