WordPress.org

Ready to get started?Download WordPress

Forums

Simple Local Avatars
Issues when used on the frontend (bbpress specifically) (3 posts)

  1. m4olivei
    Member
    Posted 10 months ago #

    Hello,

    Awesome plugin, you rock!

    I did find a couple issues though using your plugin with bbPress, which exposes a front end profile form by triggering the show_user_profile or edit_user_profile actions. There are a couple other plugins that do this (theme my login?).

    First issue is detailed here: http://wordpress.org/support/topic/i-found-a-problem-on-simple-local-avatars-20?replies=7. The jist of which is a bunch of PHP warnings are thrown b/c a there is an argument missing in the call to Simple_Local_Avatars::get_avatar()

    Next issue is with deleting an avatar. When you click Delete local avatar, it doesn't do anything. The reason for this is that your code to do the deletion happens on the action admin_action_remove-simple-local-avatar. This action will only fire when on in the WordPress dashboard, not on the front end. To fix it I did this:

    /**
     * Handle the action for removing simple local avatar
     */
    add_action('template_redirect', 'do_action');
    function do_action() {
      global $simple_local_avatars;
    
      if (!$simple_local_avatars) {
        return;
      }
    
      if (empty($_REQUEST['action'])) {
        return;
      }
      else {
        $action = $_REQUEST['action'];
      }
    
      switch ($action) {
        case 'remove-simple-local-avatar':
          if (!is_admin()) {
            $simple_local_avatars->action_remove_simple_local_avatar();
          }
          break;
      }
    }

    Then in order for that to work, I had to set the remove_nonce as it was being set in a place that was exclusive to the WordPress Dashboard. So in simple-local-avatars.php in the edit_user_profile() function, i added:

    public function edit_user_profile( $profileuser ) {
      if (!isset($this->remove_nonce)) {
        $this->remove_nonce = wp_create_nonce('remove_simple_local_avatar_nonce');
      }
      // ... rest of code
    }

    That made it work. Again great plugin, just could use some improvement to make it more useful across plugins that put profile pages on the front end too.

    Thanks!!
    Matt

    http://wordpress.org/plugins/simple-local-avatars/

  2. owster
    Member
    Posted 4 months ago #

    Hi, I'm trying to replicate this but can't seem to get it to work.

    Where have you put the first piece of code with the action hook? Wherever in simple-local-avatars.php I put it it says that do_action() is already declared in another file. And I have no luck with changing the name of the function either.

    Thank you

  3. m4olivei
    Member
    Posted 4 months ago #

    Hey,

    I put it in a custom plugin, should also work within functions.php in a theme. Change the name of the function to something other than do_action and update the call to add_action() accordingly. Sorry about that. In my plugin I have the function as a method of a class so I didn't run into that naming collision.

    Thanks,
    Matt

Reply

You must log in to post.

About this Plugin

About this Topic

Tags

No tags yet.