// ROJO'S CUSTOM CODES
// Add custom user profile fields
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) {
if ( current_user_can( 'administrator' ) ) {
?>
specific HTML code for this specific client below:
"); ?>
Stay Social by Rojo"); ?>
function( $user, $field_name, $request ) {
return get_user_meta( $user['id'], $field_name, true );
},
'update_callback' => null,
'schema' => array(
'description' => __( 'Client Report HTML' ),
'type' => 'string',
'context' => array( 'view', 'edit' ),
),
));
});
// SHORTCODE = [client_report]
function display_client_report_html( $atts ) {
$user_id = get_current_user_id(); // Or get the ID of the user whose field you want to display
$client_report_html = get_user_meta( $user_id, 'client-report', true );
return $client_report_html;
}
add_shortcode( 'client_report', 'display_client_report_html' );
// Redirect to /Dashboard page after signing in
function redirect_login_page() {
$login_page = home_url( '/login/' );
$page_viewed = basename($_SERVER['REQUEST_URI']);
if( $page_viewed == "wp-login.php" && $_SERVER['REQUEST_METHOD'] == 'GET') {
wp_redirect($login_page);
exit;
}
}
add_action('init','redirect_login_page');
function login_redirect( $redirect_to, $request, $user ){
//is there a user to check?
if (isset($user->roles) && is_array($user->roles)) {
//check for admins
if (in_array('administrator', $user->roles)) {
//Redirect them to the default place
return admin_url();
} else {
return home_url( '/dashboard/');
}
} else {
return $redirect_to;
}
}
add_filter('login_redirect', 'login_redirect', 10, 3);
// Redirect /signin to /login
function custom_redirect_signin_to_login() {
if ( strpos( $_SERVER['REQUEST_URI'], 'signin' ) !== false ) {
wp_redirect( home_url( '/login' ) );
exit;
}
}
add_action( 'init', 'custom_redirect_signin_to_login' );
// Redirect /signup to /register
function custom_redirect_signup_to_register() {
if ( strpos( $_SERVER['REQUEST_URI'], 'signup' ) !== false ) {
wp_redirect( home_url( '/register' ) );
exit;
}
}
add_action( 'init', 'custom_redirect_signup_to_register' );
// Redirect users to the base URL after logging out
function custom_logout_redirect() {
wp_redirect( home_url() );
exit();
}
add_action( 'wp_logout', 'custom_logout_redirect' );