/** * Display achievements for a user on their profile screen * * @since 1.0.0 * @param object $user The current user's $user object * @return void */ function badgeos_user_profile_data($user = null) { $achievement_ids = array(); echo '<h2>' . __('BadgeOS Email Notifications', 'badgeos') . '</h2>'; echo '<table class="form-table">'; echo '<tr>'; echo '<th scope="row">' . __('Email Preference', 'badgeos') . '</th>'; echo '<td>'; echo '<label for="_badgeos_can_notify_user"><input type="checkbox" name="_badgeos_can_notify_user" id="_badgeos_can_notify_user" value="1" ' . checked(badgeos_can_notify_user($user->ID), true, false) . '/>' . __('Enable BadgeOS Email Notifications', 'badgeos') . '</label>'; echo '</td>'; echo '</tr>'; echo '</table>'; //verify uesr meets minimum role to view earned badges if (current_user_can(badgeos_get_manager_capability())) { $achievements = badgeos_get_user_achievements(array('user_id' => absint($user->ID))); echo '<h2>' . __('Earned Achievements', 'badgeos') . '</h2>'; echo '<table class="form-table">'; echo '<tr>'; echo '<th><label for="user_points">' . __('Earned Points', 'badgeos') . '</label></th>'; echo '<td>'; echo '<input type="text" name="user_points" id="user_points" value="' . badgeos_get_users_points($user->ID) . '" class="regular-text" /><br />'; echo '<span class="description">' . __("The user's points total. Entering a new total will automatically log the change and difference between totals.", 'badgeos') . '</span>'; echo '</td>'; echo '</tr>'; echo '<tr><td colspan="2">'; // List all of a user's earned achievements if ($achievements) { echo '<table class="widefat badgeos-table">'; echo '<thead><tr>'; echo '<th>' . __('Image', 'badgeos') . '</th>'; echo '<th>' . __('Name', 'badgeos') . '</th>'; echo '<th>' . __('Action', 'badgeos') . '</th>'; echo '</tr></thead>'; foreach ($achievements as $achievement) { // Setup our revoke URL $revoke_url = add_query_arg(array('action' => 'revoke', 'user_id' => absint($user->ID), 'achievement_id' => absint($achievement->ID))); echo '<tr>'; echo '<td>' . badgeos_get_achievement_post_thumbnail($achievement->ID, array(50, 50)) . '</td>'; echo '<td>', edit_post_link(get_the_title($achievement->ID), '', '', $achievement->ID), ' </td>'; echo '<td> <span class="delete"><a class="error" href="' . esc_url(wp_nonce_url($revoke_url, 'badgeos_revoke_achievement')) . '">' . __('Revoke Award', 'badgeos') . '</a></span></td>'; echo '</tr>'; $achievement_ids[] = $achievement->ID; } echo '</table>'; } echo '</td></tr>'; echo '</table>'; // If debug mode is on, output our achievements array if (badgeos_is_debug_mode()) { echo __('DEBUG MODE ENABLED', 'badgeos') . '<br />'; echo __('Metadata value for:', 'badgeos') . ' _badgeos_achievements<br />'; var_dump($achievements); } echo '<br/>'; // Output markup for awarding achievement for user badgeos_profile_award_achievement($user, $achievement_ids); } }
/** * Filter submission messages and send one for Nomination Denial * * @param array $messages Messages to send * @param array $args Submission Args */ function badgeos_set_submission_status_nomination_denied($messages, $args) { // Check if user can be notified if (!badgeos_can_notify_user($args['user_data']->ID)) { return $messages; } $email = $args['user_data']->user_email; $args['notification_type'] = 'notify_denied'; $subject = sprintf(__('Nomination Not Approved: %s', 'badgeos'), get_the_title($args['achievement_id'])); // set the email message $message = sprintf(__('Your submission has not been approved: In response to: %1$s Nominee: %2$s Nominated by: %3$s %4$s', 'badgeos'), get_the_title($args['achievement_id']), $args['user_data']->display_name, $args['from_user_data']->display_name, get_permalink($args['achievement_id'])); // @todo set $email based on nominee and nominated by $messages['badgeos_nomination_denied'] = array('email' => $email, 'subject' => $subject, 'message' => $message); return $messages; }