Add Delete Button on View Message Page?


Home Forums Front End PM PRO Add Delete Button on View Message Page?

This topic is: Resolved

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #17356
    Louie Veleski
    Participant

    Hi Shamim,
    I wonder how to add delete button on the view message page?
    I want user be able to delete the message when they are reading the message (on the view page).

    Is there any hook / functions that I can use?

    I noticed that there is fep_delete_message( $id ) inside Fep_Message but I’m not sure how to use it.

    Thank you!

    #17360
    shamim
    Keymaster

    You can add a link like <a href="http://example.com/index.php?your_action=delete&id=1">Delete</a>. Then in init hook use that function to delete that message. Check permission and nonce first if that user have permission to do so.

    #43886
    David
    Participant

    Hi Shamim,

    I have managed to do achieve this but one problem is that fep_get_user_message_count( “total” ) is sometimes not updating after the message is deleted.

    Can I update this value somehow? It works ok when I delete a message normally but I can’t see any difference.

    Thanks for any help.

    #43891
    David
    Participant

    Ok figured it out. Full code is here if it helps anyone in the future:

    if ( isset($_GET['id']) && (isset($_GET['your_action']) == 'delete')) {
    $id = $_GET['id'];
    if ( $id && in_array( get_current_user_id(), fep_get_participants( $id, true ) ) && fep_get_message_status( $id ) == 'publish' ) {
    fep_delete_message($_GET['id']);
    delete_user_option( get_current_user_id(), '_fep_user_message_count',true );
    }
    }

Viewing 4 posts - 1 through 4 (of 4 total)

You need to purchase ‘Front End PM PRO’ to create topic in this support forum.

If you already purchased ‘Front End PM PRO’ please LOGIN.