ap_user_link( boolean|integer $user_id = false, string|array $sub = false )
Description #
Return Link to user pages.
Parameters #
- $user_idboolean | integer (Optional) user id. Default value: false
- $substring | array (Optional) page slug. Default value: false
Changelog #
Source #
File: includes/functions.php
function ap_user_link( $user_id = false, $sub = false ) { $link = ''; if ( false === $user_id ) { $user_id = get_the_author_meta( 'ID' ); } if ( empty( $user_id ) && is_author() ) { $user_id = get_queried_object_id(); } if ( $user_id < 1 && empty( $user_id ) ) { $link = '#/user/anonymous'; } else { $user = get_user_by( 'id', $user_id ); if ( ! $user ) { $link = '#/user/anonymous'; } elseif ( ap_is_addon_active( 'buddypress.php' ) && function_exists( 'bp_core_get_userlink' ) ) { $link = bp_core_get_userlink( $user_id, false, true ) . 'qa/'; } elseif ( ap_is_addon_active( 'profile.php' ) ) { $slug = get_option( 'ap_user_path' ); $link = home_url( $slug ) . '/' . $user->user_nicename . '/'; } else { $link = get_author_posts_url( $user_id ); } } // Append sub. if ( ! empty( $sub ) ) { if ( is_array( $sub ) ) { $link = rtrim( $link, '/' ) . implode( '/', $sub ) . '/'; } else { $link = $link . rtrim( $sub, '/' ) . '/'; } } $link = user_trailingslashit( $link ); return apply_filters( 'ap_user_link', $link, $user_id, $sub ); }
Expand full source code Collapse full source code View on GitHub: includes/functions.php:1467
Add your comment