Skip to:
Content
Pages
Categories
Search
Top
Bottom

Plugin: [REL] Signature

  • Hi,

    Heres my first plugin which was pretty much copied from the Avatar plugin, but hey, now I can contribute my 2 cents :) (Thanks to the guy who made that too)

    To install you must open functions.php (in bb-includes, line 1388) and add:

    'sig' => array(0, __('Signature'))

    to the end (before last closing bracket)

    This is the code:

    <?php

    /*

    Plugin Name: Signature

    Author: veb

    Version: 1.0

    */

    function post_sig() { // function to use in page php to get the sig

    if ( get_sig( get_post_author_id() ) )

    echo get_sig( get_post_author_id() );

    }

    function get_sig ( $id ) { //function to return sig lfrom database

    global $bbdb, $bb_current_user;

    $user = bb_get_user( $id );

    $profile_info_keys = get_profile_info_keys();

    if ( $id && false !== $user )

    if ( is_array( $profile_info_keys ) )

    foreach ( $profile_info_keys as $key => $label ) {

    if ( 'sig' == $key )

    return $user->$key;

    }

    }

    ?>

    Save as bb-signature.php in my-plugins.

    Have fun :D

Viewing 25 replies - 1 through 25 (of 69 total)
  • Looks good! I hope you don’t mind, but I am changing your title to have the word plugin in it as well for easy viewing!

    Trent

    Glad you used my code as a base :) I will be updating my Avatar code very soon so that functions.php no longer has to be changed. I’ll expect you to update this when I finish ;)

    Alright veb, it’s updated… so make your change ;)

    Although it MIGHT mess you up a little because I think your plugin will have to be added into mine when Avatar is used (open the new bb-avatar.php file and you’ll see why). Plus, with the new release of Avatar, if people do Signature the way you describe, it won’t work.

    I don’t know, what do you think? Maybe we should just combine the two, or have multiple releases. I don’t know how people are going to want to implement.

    I think combining them would do the job nicely, and even having it so you can have a small image as a signature too :)

    How should I implement this? Are people going to want just one AND both? ie. am I going to have to make 3 plugins here just to do 2 tasks?

    I think it would be easiest to make 2 separate plugins. One avatars, one signatures. They would both be pretty much the same, just have different effect.

    The thing is, they kinda F with each other. The way they’re implemented is they setup the profile keys seperately (via a filter). I need a way to figure out how to call the profile keys, return them and ADD one to it.

    Anyone know how to do that? S010 maybe? :)

    What if you made them in one package, but with ability to turn one off if you didn’t want it used?

    The problem is taking out the ability to enter an avatar location or signature, but the not be used. I could use S010’s admin mod to do it, but I was waiting on .74 to come out to integrate my plugins with that one.

    I dunno, I’ll think about it this evening.

    I followed the directions for adding a sig file. I have the ability to add a sig in my “edit profile” but the sigs do not come up in my posts. I’m not sure why it isn’t working.

    My boards are here: http://www.rabies-ls.com/forums/

    Any help would be appreciated. I am still a php newbie. Thank you.

    figured it out ;) I have it working now. I needed to mod post.php


    chrishajer
    Participant

    @chrishajer

    skrimpy, please share how you fixed it for the benefit of others who might run across the same problem. Thanks.

    Chris – I’d be glad to. I opened post.php (found in bb-templates or in my-templates) and modified it by placing <?php post_sig(); ?> into the code.

    my finished code section looked like this:

    <div class="threadpost">

    <div class="post"><?php post_text(); ?><?php post_sig(); ?></div>

    <div class="poststuff"><?php _e('Posted:'); ?> <?php bb_post_time(); ?> <a href="<?php post_anchor_link(); ?>">#</a> <?php post_ip_link(); ?> <?php post_edit_link(); ?> <?php post_delete_link(); ?></div>

    </div>

    I then saved and uploaded this into my-templates.

    I’m going to try and do some more customizing to get the sigs to look just the way I want them to on my forums. I’ll post if I’m successful ;)


    chrishajer
    Participant

    @chrishajer

    Thanks :)

    Does this still work anymore in bbPress 8.2?

    When I went to modify the functions.php as requested in the top thread, I didn’t find a seemingly logical place to put the code.

    Between lines 1382 and 1394:

    $topics = array_flip((array) $bbdb->get_col("SELECT topic_id, COUNT(*) FROM $bbdb->tagged WHERE tag_id = '$tag_id' GROUP BY topic_id"));

    $counts = (array) $bbdb->get_col('', 1);

    if ( $tags = $bbdb->query("DELETE FROM $bbdb->tagged WHERE tag_id = '$tag_id' AND user_id = '$user_id' AND topic_id = '$topic_id'") ) :

    if ( 1 == $counts[$topics[$topic_id]] ) :

    $tagged = $bbdb->query("UPDATE $bbdb->tags SET tag_count = tag_count - 1 WHERE tag_id = '$tag_id'");

    $bbdb->query("UPDATE $bbdb->topics SET tag_count = tag_count - 1 WHERE topic_id = '$topic_id'");

    $bb_cache->flush_one( 'topic', $topic_id );

    if ( 1 == count($counts) )

    $destroyed = destroy_tag( $tag_id );

    endif;

    endif;

    return array( 'tags' => $tags, 'tagged' => $tagged, 'destroyed' => $destroyed, 'sig' => array(0, __('Signature')) );

    }

    I put it on the second to last line, but somehow I don’t think this is correct as its not working =D.

    When I go to my profile page, there is no option to input a signature of any sorts, so obviously I can’t have a signature show up.

    Any help would be much appreciated.


    ardentfrost
    Member

    @ardentfrost

    I thought the updated plugins allowed you to adjust it in the plugin file. I know my avatar plugin works that way.


    citizenkeith
    Participant

    @citizenkeith

    Do I use the code and instructions in the first post, or is this downloadable somewhere? I didn’t see it on the Extend page.

    OK, to answer the “where do I put the code question (0.8.1)…

    In functions.php, find the get_profile_info_keys() function, which should be on or around line 1761. In the line that starts with array('user_email'..., add the following code before the last “)” in the line. Note the comma.

    , 'sig' => array(0, __('Signature'))

    This will add the signature field to the profile edit page, enabling users to input their own signatures.

    Next, we need to add the code to display the signatures in their posts. In post.php, find this line (for me it was line 17):

    <div class="post"><?php post_text(); ?></div>

    BEFORE the closing div tag, add the following:

    <?php /*Is the signature field blank?*/
    if (get_sig( get_post_author_id() ) != "") { ?>
    <div class="signature"><?php post_sig(); ?></div>
    <?php } ?>

    (NOTE: Make sure the existing closing div tag still follows the code above.)

    This checks to see if a signature exists, and if it does it adds a nested div with the signature class stylization applied to it, and the content of the signature field is placed inside this div.

    Finally, add the following to your style sheet:

    .signature {
    border-top: 1px dotted #ccc;
    margin: 5px 0 0;
    padding: 5px 0 0;
    }

    If you are using the default theme, this will style the signature div exactly like the poststuff div that follows it.

    Please note that (at this time) signatures are text-only. You may want to let your users know by adding a note in the functions.php array declaration. Something like 'Signature (text only)' would do the trick.

    I don’t know if it’s possible, but it would be nice if this plugin would be modified so that it can display images, links, and so on in the signature. Does anyone know how to do that?

    Thanks!


    citizenkeith
    Participant

    @citizenkeith

    In functions.php, find the get_profile_info_keys() function, which should be on or around line 1761. In the line that starts with array(‘user_email’…, add the following code before the last “)” in the line. Note the comma.

    , 'sig' => array(0, __('Signature'))'

    Hmm… I can’t seem to get this to work. I’ve followed your instructions, but it doesn’t show up in the Edit Profile area. Here’s my code for that section of functions.php:

    //meta_key => (required?, Label).  Don't use user_{anything} as the name of your meta_key.
    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')), 'sig' => array(0, __('Signature')))
    );
    }

    Is this correct?


    H
    Participant

    @helgetry

    It doesn’t work in my fresh installation either!


    H
    Participant

    @helgetry

    citizenkeit; if you have installed the avatar plugin, you have to edit the function in the bb-avatar.php file in your plugins folder… The function get_profile_info_keys_plus_avatar() overrides the function in the function.php file.

    Just add the code written above at the end of the get_profile_info_keys_plus_avatar() function (before the last ‘)’ ).

    Got it?

    Yes, I suppose that’s worth noting… the instructions I left above have been tested WITHOUT the avatar plugin running. From what others have said, these two plugins don’t play nice together.


    citizenkeith
    Participant

    @citizenkeith

    Ah, that did it! Thanks for the clarification.

    Any chance that we can add smilies from the emoticon plugin into the sigature? Or at least an IMG tag? :)

    In functions.php, find the get_profile_info_keys() function …

    Much neater to pluginise it like the avatar plugin has done than to hack around in the core files, but that’s the solution now anyway.

    I’m not sure how the hook ardentfrost used works specifically but the sensible thing for it to do would be to pass the infokeys array as a parameter (just like the allowed tags hook), in which case you could easily add onto whatever was already in the array. If someone’s interested it might be worth testing, again as the neatest/least problematic way of doing this.


    citizenkeith
    Participant

    @citizenkeith

    Any chance that we can add smilies from the emoticon plugin into the sigature? Or at least an IMG tag? :)

Viewing 25 replies - 1 through 25 (of 69 total)
  • You must be logged in to reply to this topic.
Skip to toolbar