Skip to content

Instantly share code, notes, and snippets.

@thebengalboy
Last active August 18, 2018 18:43
Show Gist options
  • Select an option

  • Save thebengalboy/e85bb28890c9d42f0ac7cd862aa00309 to your computer and use it in GitHub Desktop.

Select an option

Save thebengalboy/e85bb28890c9d42f0ac7cd862aa00309 to your computer and use it in GitHub Desktop.
Editing other post by WP User Frontend
//Here is the sample code, you can use to get the edit post link generated by WPUF. The code should include inside the theme's functions.php
<?php
function wpuf_get_post_edit_link( $post_id ) {
if ( !class_exists( 'WP_User_Frontend' ) || !$post_id ) {
return;
}
$edit_page = (int) wpuf_get_option( 'edit_page_id', 'wpuf_frontend_posting' );
$url = get_permalink( $edit_page );
$url = wp_nonce_url( $url . '?pid=' . $post_id, 'wpuf_edit' );
return $url;
}
//Pass the post ID inside the following function as an argument.
<?php echo wpuf_get_post_edit_link( get_the_ID() ); ?>
//Note: This method will work if you want to edit the post that was created with WPUF. However, if you like to edit a post that was not created with the WPUF, then you can select a fallback form on the wp-admin->user frontend->Settings->Frontend posting-> Default post-form-> https://prnt.sc/kk30jr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment