wordpress-sdk icon indicating copy to clipboard operation
wordpress-sdk copied to clipboard

Make it possible to check if a custom optional permission was accepted.

Open kofimokome opened this issue 1 year ago • 0 comments

🚀 feature request

Description

I recently added a custom optional permission to the opt-in screen.

function add_collectspam_permission( $permissions ) {
		$permissions['collectspam'] = array(
			'icon-class' => 'dashicons dashicons-cloud-upload',
			'label'      => kmcf7ms_fs()->get_text_inline( 'Collect Spam Info', 'collectspam' ),
			'desc'       => kmcf7ms_fs()->get_text_inline( "Collect spam words, spam emails and messages blocked", 'permissions-collectspam' ),
			'priority'   => 16,
			'optional'   => true,
			'default'    => true,
			'tooltip'    => kmcf7ms_fs()->get_text_inline( "We would like to collect only the spam words and emails saved in the plugin settings and only the messages blocked by this plugin on a regular basis", 'permissions-collectspam' ),
		);

		return $permissions;
	}

I want to check if the permission was accepted by the user. Currently, the Freemius class does not provide a method to check if a custom optional permission has been accepted

Describe the solution you'd like

Make it possible to get an instance of the FS_Permission_Manager class from the Freemius class

Describe alternatives you've considered

Manually getting an instance of the FS_Permission_Manager class

$instance = kmcf7ms_fs();
$p=FS_Permission_Manager::instance($instance);
$p->is_permission_allowed('collectspam')

But does not seem to work. It always returns false

kofimokome avatar Aug 31 '23 17:08 kofimokome