Skip to:
Content
Pages
Categories
Search
Top
Bottom

User-editable Custom Titles


  • citizenkeith
    Participant

    @citizenkeith

    I have a small site that needs very little moderation. I’d like for my users to have the power to change their own Custom Title, instead of sending me a Private Message with a request.

    I can’t figure out how to make that change, though. Any ideas?

Viewing 8 replies - 1 through 8 (of 8 total)
  • You need to write a plugin that will be called on a hook in the profile, where it adds to the associative array $profile_info_keys an entry with key ‘bb_title’ – I think. To see how to do that, look at some other plugin that adds fields to the profile info thingy.


    citizenkeith
    Participant

    @citizenkeith

    Well, I don’t know the first thing about writing plugins, so if somebody can help out, I’d appreciate it. :)


    parabolart
    Member

    @parabolart

    in functions.php find function get_profile_admin_keys() {, and move $bb_table_prefix . 'title' => array(0, __('User Title')) from that function’s array to function get_profile_info_keys()


    citizenkeith
    Participant

    @citizenkeith

    Hmm…. not sure to how to change that code without getting errors (I’m running 0.9.0.1 on this particular forum).

    function get_profile_info_keys() {
    return apply_filters(
    'get_profile_info_keys',
    array('user_email' => array(1, __('Email')), 'user_url' => array(0, __('Website')), 'from' => array(0, __('Location')), 'occ' => array(0, __('Occupation')), 'interest' => array(0, __('Interests')))
    );
    }

    function get_profile_admin_keys() {
    global $bbdb;
    return apply_filters(
    'get_profile_admin_keys',
    array($bbdb->prefix . 'title' => array(0, __('Custom Title')))
    );
    }


    philgreen
    Member

    @philgreen

    Do just like parabolart said. You should paste the text inside the () after the array for get_profile_admin_keys and separate it from the other ones with a comma.


    citizenkeith
    Participant

    @citizenkeith

    I think I need a little help with this one. I’m running 0.9.0.2 now.

    Here’s the section in functions.php:

    function get_profile_info_keys() {
    return apply_filters( 'get_profile_info_keys', array(
    'user_email' => array(1, __('Email')),
    'user_url' => array(0, __('Website')),
    'from' => array(0, __('Location')),
    'occ' => array(0, __('Occupation')),
    'interest' => array(0, __('Interests')),
    ) );
    }

    function get_profile_admin_keys() {
    global $bbdb;
    return apply_filters( 'get_profile_admin_keys', array(
    $bbdb->prefix . 'title' => array(0, __('Custom Title'))
    ) );
    }

    So if I move that section up to get_profile_info_keys, it should look like this, correct?

    function get_profile_info_keys() {
    global $bbdb;
    return apply_filters( 'get_profile_info_keys', array(
    'user_email' => array(1, __('Email')),
    'user_url' => array(0, __('Website')),
    'from' => array(0, __('Location')),
    'occ' => array(0, __('Occupation')),
    'interest' => array(0, __('Interests')),
    $bbdb->prefix . 'title' => array(0, __('Custom Title')),
    ) );
    }

    That pretty much removes everything from get_profile_admin_keys, so do I just take that entire section out?

    Thanks for the helping hand…

    I know this is an old thread, but I just wanted to say “thanks” to parabolart. I did as you suggested and it worked perfectly!


    _ck_
    Participant

    @_ck_

    Never hack the core.

    Especially when that function is right there designed to be filtered.

    see this apply_filters( 'get_profile_info_keys', array(

    It means you can make a simple plugin to modify the info keys on the fly.

    Untested but should work as a plugin:

    /*
    Plugin Name: Allow Title Edit
    */
    add_filter ('get_profile_info_keys', 'allow_title_edit');

    function allow_title_edit($array) {
    if (bb_current_user_can('participate')) {
    global $bbdb;
    $array[$bbdb->prefix.'title']= array(0, __('Custom Title'));
    }
    return $array;
    }

Viewing 8 replies - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.