[themify_is_logged_in]
[php]
/* Create CPT "Partylocation" after registration */
function create_new_party_location( $response ){
$new_user_id = $response->ID;
$new_party_location = array(
‚post_type‘ => ‚party_location‘,
‚post_title‘ => ‚Partylocation: ‚.$new_user_id,
‚post_content‘ => ‚Beschreibung der Partylocation: ‚.$new_user_id,
‚post_status‘ => ‚private‘,
‚post_author‘ => $new_user_id
);
$new_party_location_id = wp_insert_post( $new_party_location );
update_post_meta( $new_party_location_id, ‚party_location_online‘, ‚0‘ );
update_user_meta( $new_user_id, ‚party_location_id‘, $new_party_location_id );
}
add_action( ‚user_meta_after_user_register‘, ‚create_new_party_location‘, 10, 1 );
/* Custom Navigation */
function add_loginout_link( $items ) {
if ( is_user_logged_in() ) {
$current_user_id = get_current_user_id();
$party_location_id = get_user_meta( $current_user_id, ‚party_location_id‘, true );
$party_location_url = get_permalink( $party_location_id );
$items .= ‚<li><a href="‘. $party_location_url .’">Partylocation</a></li>‘;
$items .= ‚<li><a href="‘. wp_logout_url() .’">Abmelden</a></li>‘;
}
elseif ( !is_user_logged_in() ) {
$items .= ‚<li><a href="‘. site_url( ‚wp-login.php‘ ) .’">Anmelden</a></li>‘;
$items .= ‚<li><a href="‘. site_url( ‚/registrieren/‘ ) .’">Registrieren</a></li>‘;
}
return $items;
}
add_filter( ‚wp_nav_menu_mainmenu_items‘, ‚add_loginout_link‘, 10, 1 );
/* Shortcode für den Edit Button erstellen */
function ProfileEditButton(){
if( is_user_logged_in() ) {
$current_user_id = get_current_user_id();
$party_location_id = get_user_meta( $current_user_id, ‚party_location_id‘, true );
$current_post_id = get_the_ID();
if( $current_post_id == $party_location_id ){
$party_location_link = add_query_arg( array( ‚pid‘ => $party_location_id ), get_permalink( 69 ) );
$party_location_link = wp_nonce_url( $party_location_link, ‚wpuf_edit‘ );
return do_shortcode( ‚[themify_button bgcolor="blue" size="large" link="‘.$party_location_link.’"]Profil bearbeiten[/themify_button]‘ );
}
}
}
add_shortcode(‚EditProfile‘, ‚ProfileEditButton‘ );
[/php]
[/themify_is_logged_in]