dozent_user_url( null $user = null, bool $echo = true )


Parameters

$user

(null) (Optional)

Default value: null

$echo

(bool) (Optional)

Default value: true


Return

(string) Get the dozent USER Profile URL


Source

File: includes/core-functions.php

	function dozent_user_url( $user = null, $echo = true ) {
		$url = trailingslashit( home_url() ) . 'profile/';

		$user_name = null;

		if ( ! $user ) {
			$user_name = wp_get_current_user()->user_nicename;
		}

		if ( $user ) {

			//Check if the $user is user Instance and user_nicename property exists
			if ( ! $user_name && is_object( $user ) && ! empty( $user->user_nicename ) ){
				$user_name = $user->user_nicename;
			}

			//Check if the $user is an array and containing user_nicename key
			if ( ! $user_name && is_array( $user ) ) {
				$user_name = dozent_array_get( 'user_nicename', $user );
			}

			//Check if $user is object and contains user ID
			if ( is_object( $user ) && ! empty( $user->ID ) ){
				$user_name = get_the_author_meta( 'user_nicename', $user->ID ) ;
			}

			//Check if $user is user ID
			if ( ! $user_name && is_numeric( $user ) ){
				$user_name = get_the_author_meta( 'user_nicename', $user ) ;
			}
		}

		/**
		 * Filter the default nicename of dozent user URL
		 *
		 * @since DozentLMS 1.0.0
		 *
		 * @param string $user_name
		 * @param int|object $user
		 */

		$url .= apply_filters( 'dozent_user_url_nicename', $user_name, $user );

		if ( $echo ) {
			echo $url;
		}

		return $url;

	}


Changelog

Changelog
Version Description
DozentLMS 1.0.0 Introduced.