• Resolved Vova Druzhaev

    (@otshelnik-fm)


    Hi.

    I’m using a hook “asgarosforum_after_add_thread_submit”
    As by passing this “id” to get url to the created forum topic?

    This solution is not working https://www.ads-software.com/support/topic/thread/
    And I can not apply the “getLink” method.

    Maybe there is a simple function to get the title and URL on the passed “id”?
    Something like:
    asgaros_get_topic_title($id);
    asgaros_get_topic_url($id);

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Author Asgaros

    (@asgaros)

    Hello,

    you can try to use the following function to get the link:
    $asgarosforum->getLink('topic', 123);

    For the title you can do a query on the topic-table.

    Thread Starter Vova Druzhaev

    (@otshelnik-fm)

    does not work.

    https://yadi.sk/i/XFJCb-Bj3Lw8bz and https://yadi.sk/i/VSu3aaNa3Lw8ds

    function asf_url_topic(){
    
        global $asgarosforum;
        $link = $asgarosforum->getLink('topic', 8);
        
        var_dump($link);
    }
    add_action('init', 'asf_url_topic',20);

    8 (or 18) return bool(false) https://yadi.sk/i/VHDD4DVi3Lw8m7

    For the title you can do a query on the topic-table.

    – This is a stupid answer. I will explain: I can get all data everything from sql. But I can also write my own forum plug-in.
    This is the most necessary function – and you still do not have it. So I say – you are not friendly to third-party developers.

    I will repeat my question to you:

    Maybe there is a simple function to get the title and URL on the passed “id”?
    Something like:
    asgaros_get_topic_title($id);
    asgaros_get_topic_url($id);

    6 hours spent on these searches. Your plugin is unfriendly to third-party developers. I regret that I took up the development for him. Like a tangle of thread.
    Look at the ideology of the WordPress engine – a feature, as a convenient tool for third-party users. No one will recommend your plug-in – step to the side and you are at a dead end. This is bad.

    no offense.

    Thread Starter Vova Druzhaev

    (@otshelnik-fm)

    Something flew and mark “solved” was delivered. The issue is not resolved

    Plugin Author Asgaros

    (@asgaros)

    8 (or 18) return bool(false) https://yadi.sk/i/VHDD4DVi3Lw8m7

    The link-logic is set during the wp-event, so you cant use it during the init-event.

    This is the most necessary function – and you still do not have it. So I say – you are not friendly to third-party developers.

    I never said that this plugin has an API for third-party plugins. If you need that function, I can add it with the next update. Here is an example on how it could look like:

    function get_topic_title($topic_id) {
        global $asgarosforum;
        return $asgarosforum->db->get_var($asgarosforum->db->prepare("SELECT name FROM {$asgarosforum->tables->topics} WHERE id = %d;", $topic_id));
    }
    Thread Starter Vova Druzhaev

    (@otshelnik-fm)

    Ok, the event-wp returned me the result. But again, not what I asked for.
    Read 1 post:

    I’m using a hook “asgarosforum_after_add_thread_submit”
    As by passing this “id” to get url to the created forum topic?

    I once again did this:

    function asf_add_topic($topicID){
        vdl($topicID);
    }
    add_action('asgarosforum_after_add_thread_submit', 'asf_add_topic');

    created a new topic on the forum: https://yadi.sk/i/KKRZUQ4y3LwnF9
    – I saw that the action ‘asgarosforum_after_add_thread_submit’ returned me 21! How on this 21 to get a link to the forum?

    function asf_url_topic(){
    
        global $asgarosforum;
        $link = $asgarosforum->getLink('topic', 21);
        
        var_dump($link);
    }
    add_action('wp', 'asf_url_topic',20); 

    1. I pass to the ‘topic’ in method, and id 21. Get: my-site/as-forum/?view=thread&id=21 – Invalid url
    2. pass in method ‘home’. Get: my-site/as-forum/?id=21
    3. pass in method ‘forum’. Get: my-site/as-forum/?view=forum&id=21
    4. pass in method ‘current’. Get: my-site/as-forum/?view=thread&id=21
    5. pass in method ‘post’. Get: false
    – How do I get URL like in the screenshot: my-site/as-forum/?view=thread&id=10#postid-21

    On this it is logical that the function is necessary. What for then the action returns to me id which me will force to build again sql request to fetch the necessary identifier with parent_id

    I never said that this plugin has an API for third-party plugins.

    – very bad. You need to think about all users and third-party developers.

    If you need that function, I can add it with the next update.

    – Yes. It will be fine. But passing the identifier from the hook – so that there are no dances with SQL requests to fetch the necessary identifier with parent_id

    Plugin Author Asgaros

    (@asgaros)

    I’m using a hook “asgarosforum_after_add_thread_submit”
    As by passing this “id” to get url to the created forum topic?

    Please try this code for the hook:

    function asf_add_topic($id) {
    	global $asgarosforum;
    	$link = $asgarosforum->get_postlink($asgarosforum->current_topic, $asgarosforum->current_post);
    }
    add_action('asgarosforum_after_add_thread_submit', 'asf_add_topic');
    • This reply was modified 7 years, 7 months ago by Asgaros.
    Thread Starter Vova Druzhaev

    (@otshelnik-fm)

    Does not work for me: my-site/as-forum/?view=thread&id=11&part=1#postid-22

    To me in a third-party function of the id of the new forum to get a link to this forum:

    $url = asgaros_get_topic_url($id);
    – so hard to do?

    I’m writing a monitoring system for user activity and can not store url in the database. It is necessary to store the id of the created forum.
    And already on this id get a link to the forum.

    Plugin Author Asgaros

    (@asgaros)

    You wrote that you want a URL like that:

    – How do I get URL like in the screenshot: my-site/as-forum/?view=thread&id=10#postid-21

    Does not work for me: my-site/as-forum/?view=thread&id=11&part=1#postid-22

    It looks like you got it with the code!?

    To me in a third-party function of the id of the new forum to get a link to this forum

    What exactly do you want now? A link to the created topic? A link to the forum? A link to the post? The ID of the forum or post or topic? …???

    • This reply was modified 7 years, 7 months ago by Asgaros.
    Thread Starter Vova Druzhaev

    (@otshelnik-fm)

    It looks like you got it with the code!?

    But I got it inside hook “asgarosforum_after_add_thread_submit”. And I do not need to get it there.
    I have an identifier that gives hook “asgarosforum_after_add_thread_submit”. I wrote it down in the database. How on this identifier in my function to receive url of a new theme on a forum?

    A link to the created topic?

    Yes. By id who gives the hook “asgarosforum_after_add_thread_submit”

    To me in a third-party function of the id of the new forum to get a link to this forum:

    $url = asgaros_get_topic_url($id);
    – so hard to do?

    Maybe there is a simple function to get the title and URL on the passed “id”?
    Something like:
    asgaros_get_topic_title($id);
    asgaros_get_topic_url($id);

    Thread Starter Vova Druzhaev

    (@otshelnik-fm)

    like wordpress get_permalink() and get_the_title()
    link and title
    Only applicable to the forum asgaros.

    Strange that you do not have it. What’s the point then in that identifier who passed “asgarosforum_after_add_thread_submit”…

    Plugin Author Asgaros

    (@asgaros)

    Hello @otshelnik-fm

    A short update: With the next version, the following hooks will have an additional parameter which contains the topic ID as well (before it was only the ID of the post which caused the link-generation problem):
    – asgarosforum_after_add_thread_submit
    – asgarosforum_after_add_post_submit
    – asgarosforum_after_edit_post_submit

    You can find the changeset here:
    https://github.com/Asgaros/asgaros-forum/commit/212dd8535a459615b001c29a31afa9f55ec8f15c

    I will also add a new function getTopic() which allows you to get all topic-data based on its ID. Here is an example on how to use it:

    global $asgarosforum;
    $myTopic = $asgarosforum->getTopic(364);
    echo 'Topic Title: '.$myTopic->name;

    You can find the changeset here:
    https://github.com/Asgaros/asgaros-forum/commit/d688a82c2050fb703acb52b1589257daae2d8653

    With the correct topic ID you can use the function getLink() for a correct URL to your topic:

    global $asgarosforum;
    $myLink = $asgarosforum->getLink('topic', 364);

    If you dont have time to wait for the new version, you can download the development-version here (it should be stable to use):
    https://github.com/Asgaros/asgaros-forum/archive/d688a82c2050fb703acb52b1589257daae2d8653.zip

    • This reply was modified 7 years, 7 months ago by Asgaros.
    • This reply was modified 7 years, 7 months ago by Asgaros.
    Thread Starter Vova Druzhaev

    (@otshelnik-fm)

    Thank you. I got what I wanted ??

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Get url on “ID” hook’ is closed to new replies.