10/28/2015 at 11:05 am
#352164
Keymaster
@ Reed
Here’s the code that’ll create the shortcode:
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 ) );
}
}
Hope that helps!