ap_role_caps( string $role )

Description #

Get AnsPress role capabilities by role key.

Parameters #

  • $role
    string (Required) Role key.

Changelog #

VersionDescription
2.4.6Introduced.

Source #

File: includes/class/roles-cap.php

function ap_role_caps( $role ) {
	$roles = array(
		'participant' => array(
			'ap_read_question'   => true,
			'ap_read_answer'     => true,
			'ap_read_comment'    => true,
			'ap_new_question'    => true,
			'ap_new_answer'      => true,
			'ap_new_comment'     => true,
			'ap_edit_question'   => true,
			'ap_edit_answer'     => true,
			'ap_edit_comment'    => true,
			'ap_delete_question' => true,
			'ap_delete_answer'   => true,
			'ap_delete_comment'  => true,
			'ap_vote_up'         => true,
			'ap_vote_down'       => true,
			'ap_vote_flag'       => true,
			'ap_vote_close'      => true,
			'ap_upload_cover'    => true,
			'ap_change_status'   => true,
		),
		'moderator'   => array(
			'ap_edit_others_question'   => true,
			'ap_edit_others_answer'     => true,
			'ap_edit_others_comment'    => true,
			'ap_delete_others_question' => true,
			'ap_delete_others_answer'   => true,
			'ap_delete_others_comment'  => true,
			'ap_delete_post_permanent'  => true,
			'ap_view_private'           => true,
			'ap_view_moderate'          => true,
			'ap_view_future'            => true,
			'ap_change_status_other'    => true,
			'ap_approve_comment'        => true,
			'ap_no_moderation'          => true,
			'ap_restore_posts'          => true,
			'ap_toggle_featured'        => true,
			'ap_toggle_best_answer'     => true,
			'ap_close_question'         => true,
		),
	);

	$roles = apply_filters( 'ap_role_caps', $roles );

	if ( isset( $roles[ $role ] ) ) {
		return $roles[ $role ];
	}

	return false;
}

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Add your comment