WordPress.org

Ready to get started?Download WordPress

Forums

P2
[resolved] P2 and comment author url (3 posts)

  1. gbrazell
    Member
    Posted 1 year ago #

    I'm attempting to use this code in a functions.php file within my p2-child theme:

    <?php
    function force_comment_author_url($comment)
    {
        // does the comment have a valid author URL?
        $no_url = !$comment->comment_author_url || $comment->comment_author_url == 'http://';
    
        if ($comment->user_id && $no_url) {
            // comment was written by a registered user but with no author URL
            $comment->comment_author_url = 'http://www.mysite.com/profile/?uid=' . $comment->user_id;
        }
        return $comment;
    }
    add_filter('get_comment', 'force_comment_author_url');
    
    ?>

    There is no other code in that functions.php, and my reason for needing this is to force the comment url of my users to the front-end profile page created by the WP Symposium plug-in (found at this url: http://www.mysite.com/profile/?uid=_).

    Everything works perfectly with this code, comment author names link to the proper profile page of the user, except now when clicking Reply in a comment, P2 kicks this overlay error message.

    As you can see, P2 knows I'm logged into the testdude account by looking at the top right of the reply window, but it still pops the message saying I need to log-in again. It will also not allow me to click the reply button.

    Removing this functions.php file fixes the issue with P2, so it's directly related to this code and change via the child theme. Any thoughts, ideas, suggestions would be greatly appreciated.

    http://wordpress.org/extend/themes/p2/

  2. gbrazell
    Member
    Posted 1 year ago #

    I believe it has to do with my use of:

    add_filter('get_comment', 'force_comment_author_url');

    And by filtering all 'get_comment', I'm breaking functionality in p2 somewhere along the lines. Been scratching my head on how to do this without editing the p2 theme directly. Hopefully somebody has experience with p2 and comment_author.

  3. gbrazell
    Member
    Posted 1 year ago #

    This was actually a cookie issues, caused by testing in an "incognito window" which blocked wordpress and p2 from creating cookies. Thanks for being a soundboard though wordpress.org!

    Perhaps that code I posted above will help somebody in the future, cuz it works a treat for custom comment_author_urls.

    :)

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic