Skip to:
Content
Pages
Categories
Search
Top
Bottom

I made a plugin that prints the url of the user’s profile page.


  • tylertervooren
    Participant

    @tylertervooren

    I’ll start by saying I have no idea what I’m doing and I can barely write php better than a toddler.

    I noticed that people have been asking for this (or something very similar to this) for years and it still isn’t part of core and no one’s written a plugin for it. I needed to figure it out on my own, so thought I’d finally make an attempt to contribute back to a platform that has given me so much.

    bbPress Profile Link Shortcode

    It doesn’t do anything fancy, but it does what it says. Hope you find it helpful!

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

  • Robin W
    Moderator

    @robin-w

    I started with something very simple, so know the amount of work to publish a plugin and understand all the processes to that point – congratulations !!

    you can fix the broken part by only executing if the user is logged in eg

    change

    function bbp_profile_link_shortcode() {
    	
    		$link = bbp_get_user_profile_url( bbp_get_current_user_id() ) ;
    	
    	return $link;	
    }

    to

    function bbp_profile_link_shortcode() {
    	if (!is_user_logged_in())  return ;
    		$link = bbp_get_user_profile_url( bbp_get_current_user_id() ) ;
    	
    	return $link;	
    }

    This makes the function not display if the user isn’t logged in


    tylertervooren
    Participant

    @tylertervooren

    Thanks, Robin. I think I’m using a few of your plugins as well. 🙂

    The way I approached this plugin is that it’s only use is to print the url of the user profile. As you can see, no surrounding a tag and no anchor text. That means you can put it anywhere inside of your own links, which is probably even easier than trying to specify that with a shortcode attribute.

    So, if the logged in/logged out part were added, it would still break, just in a different way. 🙂

    The idea is that, if you need to check for logged in/logged out status, you probably need to do it for multiple elements of your site. In that case, a separate plugin that does that is more useful and will work in harmony with this one.

    Anyway, that was my thought process. Happy to hear other thoughts.


    Robin W
    Moderator

    @robin-w

    I hadn’t fully understood, yes I see your point now 🙂

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