Forum Replies Created
Viewing 1 replies (of 1 total)
-
In reply to: Shortcode to add “Edit Profile” link
I ended up having to dig this snippet backup for a new project and made some tweaks.
@struth Updated to only output if user is logged in.
/** * Generate BBpress Edit Profile Link in a shortcode * * @param $atts, text|class * @example [bbp_edit_profile text="Edit My Profile" class"my-link-style"] * @return string|void * */ function bbp_edit_profile_link( $atts ) { //If user isn't logged in, return nothing if(!is_user_logged_in()) { return; } else { extract( shortcode_atts( array( 'text' => "", // default value if none supplied 'class' => "" //Style class for link ), $atts ) ); if ( $text ) { $current_user = wp_get_current_user(); $user = $current_user->user_login; return '<a class="' . $class . '" href="/forums/users/' . $user . '/edit">' . $text . '</a>'; } } } add_shortcode( 'bbp_edit_profile', 'bbp_edit_profile_link' );
Viewing 1 replies (of 1 total)