Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save feliciaceballos/ef9dada5cfc51dc1584a947ef642273a to your computer and use it in GitHub Desktop.
Save feliciaceballos/ef9dada5cfc51dc1584a947ef642273a to your computer and use it in GitHub Desktop.
Create the WPMU DEV Forminator Recent Submissions Dashboard Widget, Verifying User Permissions
<?php
/**
* Setup permissions here if needed
*
* @return bool
*/
public function user_allowed() {
return true;
}
/**
* Default options of widget
*
* @return array
*/
private function get_default_options() {
return array(
'id' => $this->id,
'limit' => $this->limit,
);
}
/**
* Widget display callback
*/
public function display() {
// Check if user allowed to view the widget
if ( ! $this->user_allowed() ) {
echo esc_html( __( 'You are not allowed to view this widget content' ) );
} else {
// Get widget options
$options = $this->get_options( $this->get_default_options() );
$this->id = $options['id'];
$this->limit = $options['limit'];
// Get submissions
$this->get_submissions();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment