Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.

Tips: Method to change default avatar type of new registered user

+5 votes
802 views
asked Oct 17, 2014 in Plugins by sama55

This tips is conversation in ASKIVE. Because I think that there are many users in hope of the same (like) things, I will share it here.

Original question:

How to make default avatar on Gravatar at registration?

My (selected) answer:

Try tiny plugin below.

1. Create new plugin (e.g. qa-plugin/default-gravatar)

2. Upload qa-plugin.php under qa-plugin/default-gravatar/

<?php
if (!defined('QA_VERSION')) {
    header('Location: ../../');
    exit;
}
qa_register_plugin_overrides('qa-default-gravatar.php')

3. Upload qa-default-gravatar.php under qa-plugin/default-gravatar/

<?php
if (!defined('QA_VERSION')) {
  header('Location: ../../');
  exit;
}
function qa_create_new_user($email, $password, $handle, $level=QA_USER_LEVEL_BASIC, $confirmed=false) {
    $userid = qa_create_new_user_base($email, $password, $handle, $level, $confirmed);
    if (qa_opt('avatar_allow_gravatar'))
        qa_db_user_set_flag($userid, QA_USER_FLAGS_SHOW_GRAVATAR, true);
    return $userid;
}

This code is very simple, but you may be able to change default specifications to be related to user registeration without core hack.

Thanks Lucas.

Q2A version: 1.6.3
commented May 13, 2016 by Badan
Hi, What should be added in ('Location: ../../') ?
commented May 27, 2016 by Badan
Hi, is it also possible to store a few avatars (jpeg files) and prompt the user to chose from the list upon registration? How can this be done?

Please log in or register to answer this question.

...