Everything on this page is optional. It is here for the cases the settings do not cover.
Overriding a template #
Copy the template you want to change out of the plugin and into your theme, keeping the file name:
wp-content/plugins/wpmake-advance-user-avatar/templates/
wpmake-advance-user-avatar-upload-page.php the uploader
wpmake-advance-user-avatar-page.php the display-only avatar
to
wp-content/themes/your-theme/wpmake-advance-user-avatar/
Your copy is used instead of the plugin’s and survives plugin updates. The sub-directory name can be changed with the wpmake_advance_user_avatar_template_directory filter.
The six action hooks #
To add markup without replacing a template. Each is passed the resolved shortcode attributes.
wpmake_advance_user_avatar_before_uploaderwpmake_advance_user_avatar_before_upload_buttonswpmake_advance_user_avatar_after_upload_buttonswpmake_advance_user_avatar_after_uploaderwpmake_advance_user_avatar_before_avatarwpmake_advance_user_avatar_after_avatar
add_action(
'wpmake_advance_user_avatar_after_upload_buttons',
function ( $atts ) {
echo '<p class="description">Square photos work best.</p>';
}
);
Filters #
wpmake_advance_user_avatar_shortcode_atts— the resolved attributes for either shortcode, with the tag as the second argument.wpmake_advance_user_avatar_template_directory— the theme sub-directory templates are looked for in.wpmake_advance_user_avatar_locate_template— the resolved absolute path of a template.wpmake_advance_user_avatar_upload_url— the directory avatars are stored in.wpmake_aua_avatar_subsizes— the extra square sizes generated on upload.wpmake_aua_needs_frontend_assets— whether the front-end scripts and styles load on this request.wpmake_advance_user_avatar_wpmembers_row_position— where the field goes in the WP-Members form.pre_get_avatar_data— WordPress’s own filter, and the one this plugin supplies avatars through. Hook it at a later priority to override the plugin entirely.
Setting an avatar from your own code #
wpmake_aua_set_user_avatar( int $user_id, int $attachment_id ) : bool
wpmake_aua_remove_user_avatar( int $user_id ) : bool
wpmake_aua_current_user_can_edit_avatar( int $user_id ) : bool
wpmake_aua_get_avatar_url( int $user_id, int $size ) : string
Every avatar change in the plugin goes through the first two. Setting one checks that the user exists and that the attachment is an image; removing one clears the reference and leaves the file alone.
The two setters deliberately do not check capabilities, so an importer or a WP-CLI command with no current user can still set an avatar. Call wpmake_aua_current_user_can_edit_avatar() yourself before accepting a change that came from a request. It returns true when the target is the current user — everybody owns their own picture — or when the current user can edit_user for that person.
Two actions fire after every change, each passed the user ID and the attachment ID: wpmake_aua_avatar_set and wpmake_aua_avatar_removed.