06/24/2015 at 10:05 am
#338413
Keymaster
@ James
re: Is there a way to add a link to the ‘Edit my entry’ within other WP pages? Or even add specific fields from the the Directory? Like show the current users Name or Profile image?
Sorry, no. Do you have the Form extension? If you do, here’s a snippet that add a shortcode which will output the edit link:
add_shortcode( 'connections_edit_link', 'cn_edit_my_entry_shortcode' );
function cn_edit_my_entry_shortcode() {
// Grab an instance of the Connections object.
$instance = Connections_Directory();
// Get the current user ID.
$userID = get_current_user_id();
// Check to see if the entry has been linked to a user ID.
$entryID = get_user_meta( $userID, 'connections_entry_id', TRUE );
$results = $instance->retrieve->entries( array( 'id' => $entryID ) );
if ( is_user_logged_in() &&
( $userID == $results[0]->user && $entryID == $results[0]->id ) &&
( current_user_can( 'connections_edit_entry' ) || current_user_can( 'connections_edit_entry_moderated' ) )
) {
return cnURL::permalink( array( 'type' => 'edit', 'slug' => $results[0]->slug, 'text' => 'Edit My Entry', 'return' => TRUE ) );
}
}
I just tossed it together so it is not really tested but should work. The shortcode is [connections_edit_link].
